SEF rewrite on category view link

More
12 years 9 months ago #16830 by Clement_M
Hello,

I am using FLEXIcontent to manage Frequently Asked Questions.

In that FAQ category, I create items with the title as the Question, and the text as the Answer.

On the FrontOffice, the view is made to display FAQ category (or sub-categories) with their child items (Q&A) - so I do not use the item view (there is no link on the item title).

Page FAQ (category view)

Question 1 : Why ...?
Answer 1 : Because ...

Question 2 : Who is the ...?
Answer 2 : The ... is ...



The problem is about the search component:
when visitors search for something in the FAQ (a word in an answer for exemple), they get the result page and I want that the links to redirect to the item's category.



So I modified the FLEXIsearch plugin which created this link (flexisearch.php - line 189) :
Code:
$list[$key]->href = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->slug, $row->categoryslug));
became
Code:
$list[$key]->href = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($row->categoryslug));


It works when SEF is inactive: the link in the result list redirects to the category view of "FAQ".

But when SEF is active, the link is not correctly written:
- FLEXIcontent helper creates a link which seems to be correct

index.php?option=com_flexicontent&view=category&cid=1:categorie-1

- but the link is broked by the Jroute function

index.php/component/flexicontent/category

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

More
12 years 9 months ago #16844 by ggppdk
EXPLANATION: The Joomla Class method JRoute::_(...) tries to convert the category URL to a SEF URL it fails, due to 3 reasons
(1) it was not given an (menu) itemid, because Flexicontent helper function for category routing did not add any (menu) itemid to the URL
(2) you have no menu item pointing to the category, so when it tries to find such a (menu) itemid, it fails
(3) you are not inside com_flexicontent but inside com_search, so JRoute::_(...) will not use current itemid (if it exists)

Solutions:

1. Create a new MENU, called e.g. hidden_menu. After you create the menu delete or better unpublish the module that displays it.
In this MENU you need to add one menu item to every category you want to create a SEF link. WARNING: do not unpublish these menu items or it will not work, besides you don't need to unpublish them, since the menu is hidden (no module is displaying it)

2. Another solution is to modify FlexiContent Category Routing Helper Function to add a (menu) itemid that points to any FlexiContent Category. The bad thing is that the title of the menu item that has this itemid will appear in breadcrumbs.
UPDATE: but you can put a general name and also set menu 'item depth' to 1 to make it not clickable ;)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

More
12 years 9 months ago - 12 years 9 months ago #16846 by ggppdk
For the second solution add 2 options to the Global parameters of Flexicontent.

These options are for:

1. Default menu itemid for Items that do not have a menu item pointing to them, and also have no menu item pointing to any parent category of the item.

This is needed for SEF URLs and for displaying the title of the menu item in the breadcrubs.

In menu item options
-- Set it to point to any flexicontent item,
-- Set title to 'Site Article' or something like that
-- Set 'item depth' option to 1 to avoid making it clickable

2. Default menu itemid for categories that do not have a menu item pointing to them.

This is needed for SEF URLs and for displaying the title of the menu item in the breadcrubs.

In menu item options
-- Set it to point to any flexicontent category
-- Set title to 'Site Content' or something like that
-- Set 'item depth' option to 1 to avoid making it clickable

In file administrator/components/com_flexicontent/config.xml

Just after line: <param name="show_updatecheck" ...
ADD
Code:
<param name="default_items_itemid" type="text" size="6" default="" label="Items: Default Menu Item" description="Default menu itemid for Items that do not have a menu item pointing to them, and also have no menu item pointing to any parent category of the item.&lt;br&gt;&lt;br&gt; This is needed for SEF URLs and for displaying the title of the menu item in the breadcrubs.&lt;br&gt;&lt;br&gt; &lt;u&gt;In menu item options&lt;/u&gt;:&lt;br&gt; -- Set it to point to any flexicontent item, &lt;br&gt; -- Set title to 'Site Article' or something like that&lt;br&gt; -- Set 'item depth' option to 1 to avoid making it clickable" menu="hide" /> <param name="default_categories_itemid" type="text" size="6" default="" label="Cat/s: Default Menu Item" description="Default menu itemid for categories that do not have a menu item pointing to them.&lt;br&gt;&lt;br&gt; This is needed for SEF URLs and for displaying the title of the menu item in the breadcrubs.&lt;br&gt;&lt;br&gt; &lt;u&gt;In menu item options&lt;/u&gt;:&lt;br&gt; -- Set it to point to a any flexicontent category&lt;br&gt; -- Set title to 'Site Content' or something like that&lt;br&gt; -- Set 'item depth' option to 1 to avoid making it clickable" menu="hide" />
In file: components/com_flexicontent/helpers/route.php
in function getCategoryRoute(...) just before the
Code:
return $link;
ADD:
Code:
else { $params = JComponentHelper::getParams( 'com_flexicontent' ); $link .= '&Itemid='.$params->get('default_categories_itemid'); }
in function _findItem(...) just before the
Code:
return $match;
ADD:
Code:
if ($match==null) { $params = JComponentHelper::getParams( 'com_flexicontent' ); $defitem = new stdClass(); if ( $defitem->id = $params->get('default_items_itemid','') ) { $match = $defitem; } }
Also in this file, in function _findItem(...) i recommended commenting out the lines:
} else if ( @$globalitems && @$item->query ...
$match = $item; // priority 3 advanced ...
because they will make an article/item appear under the menu item of another article/item that is in the same category.

I think this is really unwanted behavior.

I will submit fix in the bug tracker.

NOTE that the default itemid option for Items is not needed since it does not produce an error.
but i think we should comment out the 2 above lines.

UPDATE 10/7/2011: corrected the above code as it gave an error in the backend (in category Management).

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 12 years 9 months ago by ggppdk.

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

More
12 years 9 months ago - 12 years 9 months ago #16860 by ggppdk
...


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 12 years 9 months ago by ggppdk.

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

More
12 years 9 months ago #16868 by ggppdk
UPDATE: changed and corrected the above code as it gave an error in the backend (in category Management).


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

More
12 years 9 months ago #16876 by Clement_M
Hi,
thank you for your answers :D .
I tried the second solution, because the first one is too much constraining for the users.

But, at this time it does not work.
And there is 2 things I don't understand because in file: components/com_flexicontent/helpers/route.php
in the function getCategoryRoute(...), there is no
Code:
return $match;
but there is
Code:
return $link;
and in the function _findItem(...), there is no
Code:
return $link;
but there is
Code:
return $match;

I think made a mistake.
Is there an order to follow to implement that solution?

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.277 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline