Page 1 of 1

Link LISE items to Menu

Posted: Sun Jun 24, 2018 7:17 pm
by brentnl
Hi,

I've a LISE-module and want to link every item to its own content-page.

It's for a medical-website where every treatment has it's own page and where every treatment also has a certain specialist (a person). Those specialists are listed in a LICE-instance.

I know it's possible to add a 'content page field definition', but a want to do it the other way arround. So I want to achieve a dropdown or somekind while editing a contentpage were I could select a LISEitem (the person/specialist).

What is the easiest way to achieve this?

Re: Link LISE items to Menu

Posted: Sun Jun 24, 2018 9:19 pm
by velden
Just an idea: wouldn't it be possible to use LISE as a replacement for the specific content pages?

There are ways to 'insert' LISE links into the menu.

If not I would have a look at http://dev.cmsmadesimple.org/projects/ecb2 and create a UDT to fill the dropdown_from_udt content block.

The LISE api allows for creating such an UDT or it could be a rather simple database query too. I don't have a working example though.

Re: Link LISE items to Menu

Posted: Sun Jun 24, 2018 9:22 pm
by brentnl
velden wrote:...
There are ways to 'insert' LISE links into the menu.
..
How could this be done? ;D

Re: Link LISE items to Menu

Posted: Sun Jun 24, 2018 9:33 pm
by DIGI3
You can use CGContentUtilties to create a dropdown that displays a list of your LISE items. In CGCU create a dropdown block called 'lise_items' and put this in the 'options' field (replace [instance] with your instance name):

Code: Select all

{cms_module|strip_tags module='LISE[instance]' template_summary='options'}
Then in your LISE instance, create a summary template called 'options':

Code: Select all

{foreach from=$items item=item}
{$item->name}|{$item->alias}
{/foreach}
Then in your page template:

Code: Select all

{content_module module='CGContentUtils' block='lise_items'}
I'm going from memory so the above may not be exactly right, but it should be pretty close.

Re: Link LISE items to Menu

Posted: Sun Jun 24, 2018 9:33 pm
by velden
Create a LISE summary template that outputs the html like you need it for your menu.

Inside the Navigator template create some logic to find the right place in the menu and insert a LISE tag with the specific template there.

Challenge will be to give a specific LISE item a 'current' or 'active' class when it's the selected 'page'. But not impossible.


Another option would be http://dev.cmsmadesimple.org/projects/cgsmartnav

Re: Link LISE items to Menu

Posted: Mon Jun 25, 2018 9:12 pm
by brentnl
DIGI3 wrote:You can use CGContentUtilties to create a dropdown that displays a list of your LISE items. In CGCU create a dropdown block called 'lise_items' and put this in the 'options' field (replace [instance] with your instance name):

Code: Select all

{cms_module|strip_tags module='LISE[instance]' template_summary='options'}
Then in your LISE instance, create a summary template called 'options':

Code: Select all

{foreach from=$items item=item}
{$item->name}|{$item->alias}
{/foreach}
Then in your page template:

Code: Select all

{content_module module='CGContentUtils' block='lise_items'}
I'm going from memory so the above may not be exactly right, but it should be pretty close.
This works great so far!
And how can I access the other fields of the lise-item? I could do something like this;

Code: Select all

{capture assign="foo"}{content_module module='CGContentUtils' block='lise_items'}{capture}
 {LISE[instance] item='$foo' template_detail='page-view'}
But I rather have the fields available in the page-template itself, instead of making a detail-template in the LISE instance.

Re: Link LISE items to Menu

Posted: Mon Jun 25, 2018 10:07 pm
by DIGI3
You could create a detail template that assigns all of the fields to variables, which you can then call from within your page template anywhere after the lise call.

Also, try to avoid {capture}, it's more efficient to assign variables.

Code: Select all

{$foo="{content_module module='CGContentUtils' block='lise_items'}"}

Re: Link LISE items to Menu

Posted: Tue Jun 26, 2018 7:36 am
by velden
And how can I access the other fields of the lise-item? I could do something like this;
Code:
{capture assign="foo"}{content_module module='CGContentUtils' block='lise_items'}{capture}
{LISE[instance] item='$foo' template_detail='page-view'}
You could but it wouldn't work :-) Don't use variables inside single quotes, they won't be evaluated. Preferably don't use quotes at all around variables (and tags).

So, about this 'variables' being accessible in the page template. Consider this:

Create a LISE detail template (name 'empty') with only this code:

Code: Select all

{$LISEitem=$item scope=global}
Then in your page template, AFTER the

Code: Select all

{content_module module='CGContentUtils' block='lise_items' assign=foo}
(note the assign parameter, obviously the best and easiest way to assign the output to a variable in this case)

Code: Select all

{LISEinstance item=$foo template_detail=empty action=detail assign=dummy}
assign=dummy is optional because the 'empty' template should not output anything anyway.

Now you can use in your page template the $LISEitem OBJECT like you would inside the LISE detail template itself (but use $LISEitem instead of $item).

E.g.:

Code: Select all

$LISEitem->title
$LISEitem->fielddefs['<FIELDDEF_ALIAS>']->value