LISE: module sharing info with other LISE modules

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

LISE: module sharing info with other LISE modules

Post by blackrain »

I am trying to get a LISE page to display the selected items from another LISE module, I am failing to grasp how this actually works and get it to do what I want.

I am using CMSms 2.1.6 with LISE 1.2.3

The instances in question are LISEPeople and LISESpecialisms

I have created a 'field definition' for 'specialisms' using 'LISE Instance Item'.
this allows me to import a list of 'specialisms' to the the 'people item'.

I have selected '4 specialisms' as sample data.

I then used the code template generated by the field_definition selection

Code: Select all

{LISELoader item='specialism' force_array=1 value=$item->fielddefs.specialism assign='items'}
{$item->fielddefs.specialism}: {$items|implode:','}
The front end shows the following error:

Code: Select all

00001: Discrete LISE error: {LISELoader}: Unknown item type! @ /root/to/directory/httpdocs/modules/LISE/lib/class.LISELoader.php (97)
What I am trying to achieve is the item page for 'people' shows all the persons details and a list of clickable links to the specialisms they are related to.

I am at a loss here as the project relies on association of content form several sections.

I would very much appreciate any help on this.

Thanks

Mark
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE: module sharing info with other LISE modules

Post by Jo Morg »

blackrain wrote:

Code: Select all

{LISELoader item='specialism' force_array=1 value=$item->fielddefs.specialism assign='items'}
{$item->fielddefs.specialism}: {$items|implode:','}
The front end shows the following error:

Code: Select all

00001: Discrete LISE error: {LISELoader}: Unknown item type! @ /root/to/directory/httpdocs/modules/LISE/lib/class.LISELoader.php (97)
item='specialism' is not a valid item parameter for LISELoader. Valid parameters are item or category. Additionally LISELoader will assume the current module instance as the target to get data from if the instance parameter is not explicitly defined, which in your case is wrong since you want to get data from LISESpecialisms, so the following should work (untested though):

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='items'}
{$item->fielddefs.specialism}: {$items|implode:','}
However assigning it's output to items is a recipe for disaster, because if you are inside the default loop you will be overwriting the already existing smarty variable {$items} and the loop will fail at some point...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Thanks Jo,

What parameters are available with this module, I would like each of the 'specialism' items to be clickable and apply some styling to them.

Code: Select all

 <a href="/{$entry}"><button class="btn btn-grey">{$entry}</button></a>
this would create a clickable button for each 'specialism'.

thanks for your help on this, you are a real life saver.


Thanks

Mark
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Hi,

just to clear up what I need to do and I freely admit failing to do is split a comma separated list returned by the LISELoader.
e.g.
Item One,Item Two,Item Three
its just a list of text and i need the text to be more formatted, So I am trying to find out the additional parameters available to use, like alias of the LISELoader list

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='items'}
{foreach from=$item->fielddefs.specialism.value item=entry}
<a href="/{$entry.alias}"><button class="btn btn-grey">{$entry.title}</button></a>
{/foreach}
Now the above code does not work, but thats where I am at the moment, any pointer would be a great help as I am drowning here.

many thanks

Mark
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE: module sharing info with other LISE modules

Post by velden »

JoMorg already warned that using the 'items' variable for the new items wasn't a good idea.

Further, try to understand what you do. You're foreach-ing a single value or something in your last code example.

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='items'} /*  <-- you assigned to $items here. Better use another name */
/* enumerating '$item->fielddefs.specialism.value' makes no sense at all. Enumerate the previously assigned variable --> */
{foreach from=$item->fielddefs.specialism.value item=entry}
<a href="/{$entry.alias}"><button class="btn btn-grey">{$entry.title}</button></a>
{/foreach}
Inside the loop print the available properties/values first so you know what you can use. I think it's a bad idea to use '/{$entry.alias}' for the href value.

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='whatever'} 

{foreach from=$whatever item=entry}
<pre>{$entry|print_r}</pre>
{/foreach}
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Hi Velden,

thanks for getting back to me, the example was the kind of thing I wanted to produce but with the correct syntax, Jo already displayed the code I required to get a list of the checked 'specialisms' but the list is a concatenation of all the checked items.

I wanted to know the correct way to split the list into clickable buttons.

I don't know the available parameters for the LISE Instance field definition that are available in the parent LISE Instances like 'url' as the documentation does not explain the 'LISE Instance field definition'.

thanks for your help it is very much appreciated.

Mark
flmm
Forum Members
Forum Members
Posts: 41
Joined: Wed Mar 24, 2010 1:12 pm

Re: LISE: module sharing info with other LISE modules

Post by flmm »

// Example list
$specialisms = item1,item2,item3,item4,item4

// Split the comma seperated list
{$specialisms = ","|explode:$specialisms}

// Do the foreach
{foreach from=$specialisms item=specialism}
<a href="/{$specialism}"><button class="btn btn-grey">{$specialism}</button></a>
{/foreach}
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Thanks flmm,

I had started I have found the solution post but looks like you beat me to it, just what i needed though great answer.

my solution/hack for the issue.

I would however love to know how the LISE module works and how it can be used in filtering results but that another post i'm guessing.
here is the solution I found in its entirety. looks like we had the same idea, got mine from smarty.net forum and needed to add lower|replace to make the url work properly though.

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='specialisms'}

{assign var="specialisms" value=","|explode:$item->fielddefs.specialism}
 
{section name=i loop=$specialisms}
    <a href="/specialisms/{$specialisms[i]|escape|lower|replace:' ':'-'}"><button class="btn btn-grey">{$specialisms[i]|escape}</button></a>
{/section}

thanks again, for you help everyone that posted.

Mark
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE: module sharing info with other LISE modules

Post by velden »

Code: Select all

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='specialisms'}
So here you're calling the LISELoader to do stuff for you and assign the result to the variable 'specialisms'.

Code: Select all

{assign var="specialisms" value=","|explode:$item->fielddefs.specialism}
In the very next line of code you're overwriting this 'specialisms' variable. So it seems you can skip the first line completely...
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Hi Velden,

By removing either of the lines, the function breaks, also if I rename the first assign to, say 'entries' it also breaks.

I will probably leave it as it is as assigning a variable and over writing it later is not a major issue really.

Thanks for looking at it though, your help has been much needed.

Mark
flmm
Forum Members
Forum Members
Posts: 41
Joined: Wed Mar 24, 2010 1:12 pm

Re: LISE: module sharing info with other LISE modules

Post by flmm »

{LISELoader instance='LISESpecialisms' item='item' force_array=1 value=$item->fielddefs.specialism assign='specialisms'}

{$specialisms = ","|explode:$specialisms}

{section name=i loop=$specialisms}
<a href="/specialisms/{$specialisms|escape|lower|replace:' ':'-'}"><button class="btn btn-grey">{$specialisms|escape}</button></a>
{/section}
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: LISE: module sharing info with other LISE modules

Post by blackrain »

Sorry flmm,

that doesn't work, the solution above seems to be the best fit for this project

Thanks

Mark
Post Reply

Return to “The Lounge”