- Posts: 10
COMMUNITY FORUM
Attachment doesn't work with advanced sef
- Nicola
-
Topic Author
- Offline
- New Member
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
At some point it call this query:
SELECT *
FROM radgw_k2_attachments
WHERE itemID=83
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
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
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
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.
Please Log in or Create an account to join the conversation.
- Nicola
-
Topic Author
- Offline
- New Member
- Posts: 10
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- New Member
- Posts: 10
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.