[SOLVED] Link to 2-nd level category from item?

More
7 years 7 months ago - 7 years 7 months ago #63912 by lipatovroman
Hi!
I have such a structure on the site:

software
-windows
--maincat
---subcat
-macOS
--maincat
---subcat

How to create links from items on 2-nd level category: Windows or macOS?
Items should have text like "operating system" and it should be a link to category.



So, I need to build automatic links to 2-nd level category in item.php template.
Thanks.
Last edit: 7 years 7 months ago by lipatovroman.

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

More
7 years 7 months ago - 7 years 7 months ago #63994 by ggppdk
Hello

you want to link 2 parent categories upwards the tree, you can do this :

1. create a text field
2. set a default value (ANY TEXT) and set parameter "display default instead of empty"
3. create a custom layout for it , so that you can add custom HTML code to it
4. inside it use:
Code:
$catshelper = new flexicontent_cats($cid); $parents = $catshelper->getParentlist($all_cols=false); if ( count($parents)>=3 ) { $cat = $parents[ count($parents) - 3 ]; $cat_icon = '........'; echo '<a title="'.$cat->title.'" href="'.JRoute::_( FlexicontentHelperRoute::getCategoryRoute($cat->slug) ).'">'.$cat_icon .'</a>' }


-- 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: 7 years 7 months ago by ggppdk.
The following user(s) said Thank You: lipatovroman

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

More
7 years 7 months ago - 7 years 7 months ago #63997 by ggppdk
Hello

see previous message

i think you had opened a forum thread (i cannot find it now )
- about FILE field (and minigallery) not showing in the popup the currently selected file (red strikethrough line)

The above is now implemented (commited to github repository)


-- 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: 7 years 7 months ago by ggppdk.

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

More
7 years 7 months ago - 7 years 7 months ago #64008 by lipatovroman

ggppdk wrote: Hello

you want to link 2 parent categories upwards the tree, you can do this :

1. create a text field
2. set a default value (ANY TEXT) and set parameter "display default instead of empty"
3. create a custom layout for it , so that you can add custom HTML code to it
4. inside it use:

Code:
$catshelper = new flexicontent_cats($cid); $parents = $catshelper->getParentlist($all_cols=false); if ( count($parents)>=3 ) { $cat = $parents[ count($parents) - 3 ]; $cat_icon = '........'; echo '<a title="'.$cat->title.'" href="'.JRoute::_( FlexicontentHelperRoute::getCategoryRoute($cat->slug) ).'">'.$cat_icon .'</a>' }


Hi! Thanks!
Can I use this code right in template?
I think that if I'll use extra field for this it may loss of performance site...

PS

you want to link 2 parent categories upwards the tree

I think that I want to link child categories downwards with 2-nd level from main parent category.
root
-software
--windows
--macos
--android
--linux
Last edit: 7 years 7 months ago by lipatovroman.

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

More
7 years 7 months ago - 7 years 7 months ago #64084 by lipatovroman
Sorry, but this code does not work...

I tried to find issue and removed part of code.

So, now I trying this code:
Code:
$catshelper = new flexicontent_cats($cid); $parents = $catshelper->getParentlist($all_cols=false); echo count($parents);

It always displays - 0.
Last edit: 7 years 7 months ago by lipatovroman.

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

More
7 years 7 months ago - 7 years 7 months ago #64085 by lipatovroman
When I use this code
Code:
$catshelper = new flexicontent_cats($cid); $parents = $catshelper->getParentlist($all_cols=false); echo new flexicontent_cats($cid); echo count($parents);

I getting errors:

Notice: Undefined variable: cid in /var/www/user/data/www/site.ru/plugins/flexicontent_fields/text/tmpl/value_default2.php on line 19
Notice: Undefined variable: cid in /var/www/user/data/www/site.ru/plugins/flexicontent_fields/text/tmpl/value_default2.php on line 22
Catchable fatal error: Object of class flexicontent_cats could not be converted to string in /var/www/user/data/www/site.ru/plugins/flexicontent_fields/text/tmpl/value_default2.php on line 22

PS We should to get $cid before.

I added code before - $cid = $item->catid;
and I use it right in template, not in field.
Last edit: 7 years 7 months ago by lipatovroman.

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.288 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