How to access category alias with ListIt2Loader?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

How to access category alias with ListIt2Loader?

Post by Simon66 »

I'm using ListIt2 and ListIt2Loader to pull in the categories, but I need to output the alias instead of the name.

This is the code I'm using:

Code: Select all

{ListIt2Loader item='category' force_array=1 instance='ListIt2Portfolio' value=$item->categories assign='cats'}
<li class="item" data-id="id-{$smarty.foreach.count.iteration}" data-type="{$cats|implode:','}">
The $cats array outputs the names of the associated categories but I can't output the alias.

Using |print_r to view the contents of the $cats array I get this:

Code: Select all

Array
(
    [4] => ListIt2Category Object
        (
            [category_id] => 4
            [alias] => style-guides
            [name] => Style Guides
            [description] => 
            [active] => 1
            [position] => 1
            [parent_id] => -1
            [hierarchy] => 00001 etc.
Any ideas on accessing the alias?
Stikki

Re: How to access category alias with ListIt2Loader?

Post by Stikki »

{foreach name=$cats item='one_cat'}
{$one_cat->alias}
{/foreach}
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Re: How to access category alias with ListIt2Loader?

Post by Simon66 »

Thanks Stikki! ;D
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: How to access category alias with ListIt2Loader?

Post by JM6891 »

Thank you - also helped me out too!
User avatar
noosphere
Forum Members
Forum Members
Posts: 54
Joined: Tue Feb 26, 2008 9:20 am

Re: How to access category alias with ListIt2Loader?

Post by noosphere »

Stikki wrote::-D
Hello Stikki and all others on the forum!
I'm trying to get the ListIt2 categories to populate my Advanced Content dropdown in the backend to select different playlists based on the ListIt2 categories.

Here's what I got so far:

1. my udt named "get_cat"

Code: Select all

$data = "{ListIt2Loader item='category' force_array=1 instance='ListIt2Courses' value=$item->categories assign='cats'}";
$mycats = implode(",", $data);
echo $mycats;
2. my page template calling the udt

Code: Select all

{content block="playlist" label="Select Playlist" block_type="dropdown" items=":::get_cat:::" assign="playlist" editor_groups="Admin,Editor" smarty="true"}
But I'm not getting any data back.

3. also tried with different options

Code: Select all

$data = "{ListIt2Courses action='category'}";
//which returns my categories separated by |
//echo $smarty->display('eval:'.$smarty_data);
// ECHO in frontend displays the categories correctly
$smarty->display('eval:'.$data);
// but in both cases the backend page is blank !

Do you or anybody else out here have any suggestion/hint for me please ?

Thank you in advance and thank you for your great module !
#Ed
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: How to access category alias with ListIt2Loader?

Post by velden »

Some considerations:

1. you can't use Smarty tags in UDT
2. echo $data will output $data, you'd need return $data but it will not work because of 1.
3. what's that ':::get_cat:::' syntax? I don't know it.
4. I don't know if you can use this approach in backend/admin at all (calling listit2loader and do something with the results in the next {content} block.)
Stikki

Re: How to access category alias with ListIt2Loader?

Post by Stikki »

Like Velden said don't use Smarty tags inside PHP.

Use Module API functions and ListIt API functions to gain what you want. All public methods are in main module class (ListIt2.module.php).

Reason why i don't provide code snippet is because it's custom coding your doing and wish no copy-paste guys to get their hands into it.
Post Reply

Return to “Modules/Add-Ons”