Keyword

Attachment doesn't work with advanced sef

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #157868 by Nicola
Hello, I've opened an issue on github ( github.com/getk2/k2/issues/361 ). Here is the problem:
I've a category called news and a subcategory called breaking news.
I also have a menu item called news that show all news from subcategories (like breaking news).

With Advanced SEF and this settings:
URL Prefix for Category: none
use ID for article: no
use alias for article: yes
use category id: no
use category alias: yes

It works
But, If I set "URL Prefix for Category" to "article category", attachments return error 404
the url is domain.tld/news/download/"hash".html ->error 404

if I disable URL Prefix for Category the url is
domain.tld/news/download/"hash".html ->work

Am I doing something wrong?

Thank you

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #157882 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
So the alias is printed in the attachment.

As a temporary measure, until we fix it, you can try a quick and dirty solution.

In the item.php file you change:
<?php echo $attachment->link; ?>[code]

with:
[code]
<?php $realLink = str_replace('news/', '', $attachment->link); ?>
<?php echo $realLink; ?>

The end result should be:
<?php $realLink = str_replace('news/', '', $attachment->link); ?>
<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $realLink; ?>">

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago - 8 years 7 months ago #157888 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
Hello, I wrote wrong things and I'm sorry for that:
without advanced sef:
www.domain.tld/news/item/{id}-title.html
www.domain.tld/news/download/*hash*.html <- it works

with advanced sef but without category prefix
www.domain.tld/news/{id}-title.html
www.domain.tld/news/download/*hash*.html <- it works

with advanced sef and category prefix
www.domain.tld/news/sport/{id}-title.html
www.domain.tld/news/download/*hash*.html <- it doesn't work

if I manually wrote
www.domain.tld/news/sport/download/*hash*.html <- it works
Last edit: 8 years 7 months ago by Nicola.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #157900 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
I tested all prefixes with advanced SEF using the 2.7.2 DEV version.
It is working as expected.

I will map the master category in a menu item to replicate your setup.
Is sport a menu item as well?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago - 8 years 7 months ago #157904 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
I'm sending you via PM the correct urls of this website :-)

EDIT: I don't see the PM function, so no, the category is called "notizie" (I've translated for you from italian to english). The subcategory is called "discipline".
The attachment doesn't have spaces or something else.

Thank you
Last edit: 8 years 7 months ago by Nicola.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #157905 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
You can use the contact form
www.joomlaworks.net/support/contact

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #157928 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef

Krikor wrote: You can use the contact form
www.joomlaworks.net/support/contact


Hello, I've sent the email yesterday, hope it's arrived :-)

Thanks

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #157935 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
Yes, It arrived I will look into it.
Thank you once again Nicola for reporting this.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #158079 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
Hello, I’ve installed latest version from github, disabled redirect plugin, and same as before.

Without sef advance it works, with sef advance now it’s different:

if I use a custom prefix for article like “articolo”, download works, because the url is:
www.domain.tld/articolo/download/2_2204504bf19c4fc29d778e7a158fd5c1.html

If I use article category, attachment download return error 404 (the category isn’t present in url) because the url is:
www.domain.tld/notizie/download/2_2204504bf19c4fc29d778e7a158fd5c1.html

The category name isn’t wrote inside url.

I’ve created a new category called ‘cat’, with mother category ‘notizie’.
Then I wrote an article inside this category: same as before; with category as prefix it doesn’t work. It’s a render problem because if I manually wrote the category name inside the url it download the attached file.

So I've checked your url that work:

parent-category/another-cat/item/id-alias/download/hash is working properly.


it's different from mine, I've:
domain.tld/parent-category/download/hash

But if I manually wrote
domain.tld/parent-category/another-category/download/hash it works

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #158089 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
Can you try the following:
Disable the redirect extension,
install the DEV version.
github.com/getk2/k2

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #158090 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
Hello, it's the first test I've done as you suggested. Deleted every record inside redirect component, disabled redirect plugin, installed latest from github.
Same as before. Today I try with an empty website to understand if it's a problem of this website.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #158092 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
Let me know on the results.
Also try with the site both cached and uncached.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #158113 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
In a new website it works without problems. Now I look what it's different between two websites ;)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #158117 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
Great news Nicola :)
Let me know when you locate the culprit.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago - 8 years 7 months ago #158125 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
Hello, I've found the problem.
At some point it call this query:
SELECT * 
  FROM radgw_k2_attachments 
  WHERE itemID=83
And it works. Then with this query:
SELECT items.id, categories.id AS catid, 
  CASE WHEN CHAR_LENGTH(categories.alias) THEN CONCAT_WS('-', categories.id, categories.alias) ELSE categories.id END AS catslug 
		
  FROM radgw_k2_items AS items 
		
  INNER JOIN radgw_k2_categories AS categories 
  ON items.catid = categories.id 
		
  WHERE items.id = 1
it return 0. Because the ID is wrong. If I manually wrote:
SELECT items.id, categories.id AS catid, 
  CASE WHEN CHAR_LENGTH(categories.alias) THEN CONCAT_WS('-', categories.id, categories.alias) ELSE categories.id END AS catslug 
		
  FROM radgw_k2_items AS items 
		
  INNER JOIN radgw_k2_categories AS categories 
  ON items.catid = categories.id 
		
  WHERE items.id = 83
it works as expected.

EDIT: If I uninstall k2 and Install again, it works. I can't understand where to look

Edit2: Now I'm able to reproduce the error:
1) install version 2.7.0 and play with categories and articles: create a few and delete them. Empty trash, create again a few, and delete them.
2) Upgrade to version 2.7.1, empty trash and create categories with articles. The error is here. In this case the article

For example, the article now have id: 3 (but it's strange because I've created other articles before). BTW, it use this code:
SELECT * 
  FROM radgw_k2_attachments 
  WHERE itemID=3
and then:
SELECT items.id, categories.id AS catid, 
  CASE WHEN CHAR_LENGTH(categories.alias) THEN CONCAT_WS('-', categories.id, categories.alias) ELSE categories.id END AS catslug 
		
  FROM radgw_k2_items AS items 
		
  INNER JOIN radgw_k2_categories AS categories 
  ON items.catid = categories.id 
		
  WHERE items.id = 2

EDIT 3: for some reason it fetch the id of attachment and not the Id of article. Infact, If I change the attachment id to 3 in database, it works as expected.
Last edit: 8 years 7 months ago by Nicola.

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 6 months ago #158199 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
I'm sorry to bump but Am I the only one with this issue?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago #158201 by Krikor Boghossian
Replied by Krikor Boghossian on topic Attachment doesn't work with advanced sef
I take it, this is from the debug console.
can you give me some context?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Nicola
  • Nicola's Avatar Topic Author
  • Offline
  • New Member
More
8 years 6 months ago #158202 by Nicola
Replied by Nicola on topic Attachment doesn't work with advanced sef
Sure, I've found why the url of attachment with advanced sef is wrong. It can't load the category ID because instead use the category ID it use the attachment ID.
This happen after upgrade from 2.7.0 to 2.7.1 and after create and delete some articles and category.
I don't have a perfect "step by step" method to reproduce, but the query explain what I'm talking about: for some reason (and I don't know why) it's looking for attachment ID instead category ID.
So if I've an attachment ID 20 and I don't have category ID 20 the url is missing the /category/ part and it generate 404 error.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum