LISE: Connecting an item with a detail view of a second instance Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
antibart
Power Poster
Power Poster
Posts: 1155
Joined: Sun Aug 17, 2008 9:29 am

LISE: Connecting an item with a detail view of a second instance

Post by antibart »

Hi,

as described in the title: I'm wondering, if it may be possible to connect a single item of instance A with a detail view of instance B by using the $item->url tag, not by inserting the generated url manually.

For example (simplified summary template of instance A):

Code: Select all

{foreach from=$items item=item}
{if $item->alias == 'alias1'}
	{$item->url} to detail of instance B
	{else}
	What usually happens
{/if}
{/foreach}
How could I "catch" and seperate the {$item->url} tag of a second instance?

I've already tried quite a few with LISELoader. But I confess I'm still struggling a lot with LISELoader.

Any ideas?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE: Connecting an item with a detail view of a second instance

Post by Jo Morg »

I'm not sure I understand why you would want to use the url for this. The loader is not useful for that purpose either. In my opinion you are overthinking it a bit as you an call the second instance via the normal tag with the correct parameters. You will have to have some sort of connection from one instance to another though: that's why there are field types LISEInstance and LISEInstanceItem. That the best way to connect several instances and instance items as you would a relational database.
Then you could do things like this:

Code: Select all

{foreach from=$items item=item}
  {LiseInstanceB action=detail item=$item->instanceB_item_alias}
{/foreach}
"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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE: Connecting an item with a detail view of a second instance

Post by velden »

And if you really only need the url consider {cms_action_url}

Of course combined with Jo Morg's loop (untested):

Code: Select all

{foreach from=$items item=item}
  {cms_action_url module=LiseInstanceB action=detail item=$item->instanceB_item_alias}
{/foreach}
antibart
Power Poster
Power Poster
Posts: 1155
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: Connecting an item with a detail view of a second instance

Post by antibart »

Thank you Jo and Velden,


Jo Morg wrote: Wed Oct 14, 2020 12:59 pm I'm not sure I understand why you would want to use the url for this.
Currenty it is no longer needed to get to detailpage of instance B. But it is still not finished. I try to explain what this is all about.

Instance A is the home page. An image gallery. All images are reffered to other content pages with image galleries (LISE module instances).

So Instance B is also an image gallery, but with a simple kind of shop function (not in a legal sense, the contract will be made later). A gallery of books and calendars, some of them can be ordered/reserved - but only temporarliy. For that the detail view shows a formbuilder form. Product title and price of the item are transfered automatically to the mail form template.

And there is also a a field definition named "counter" to insert a number of the article in stock. A little selfmade plugin causes that everytime a mail has been sent one number is subtracted from the counter. As soon as 0 is reached, the order button disappears.
{if $item->fielddefs.count ne '' && $item->fielddefs.count ne '0'}<a class="order" href="{$item->url}" title="order {$item->title}">Order</a> {/if}
So my first idea was: While an images in the shop is marked as a sales article it should be able to be ordered from the hompage too.
That is why I could not work with a seperated detail view in instance A.The identical article would be handled as two articels.

But as I said the detail URL of instance B is no longer needed in instance A. instead a text alert like "order now" should be displayed in some selected items of the summary of instance A (=home page). I helped myself with a field definition "show alert". It's not a perfect solution because the alert has to be deactivated manually when the article is sold out.

Perfect was when the alert text on the home page would depend on the counter of the shop too. As shown in the code above. But for that I need to have access to the counter field definition of instance B (=shop).
Jo Morg wrote: Wed Oct 14, 2020 12:59 pm
Then you could do things like this:

Code: Select all

{foreach from=$items item=item}
  {LiseInstanceB action=detail item=$item->instanceB_item_alias}
{/foreach}
When I do that a detail view of instancs B is displayed in instance A with normal text only. Field definitions and If/elses will be ignored.
Last edited by antibart on Fri Oct 16, 2020 12:36 pm, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE: Connecting an item with a detail view of a second instance

Post by velden »

If you connect the items of instance A with items of instance B, you can get what you want. Like Jo Morg already wrote; using a field definition in instance A of type: LISEInstanceItem.

Then you can use LISELoader (read the LISE help) to get the linked item object and read the counter from it.
It really is possible and not too hard once you get it.
antibart
Power Poster
Power Poster
Posts: 1155
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: Connecting an item with a detail view of a second instance

Post by antibart »

velden wrote: Fri Oct 16, 2020 12:30 pm If you connect the items of instance A with items of instance B, you can get what you want. Like Jo Morg already wrote; using a field definition in instance A of type: LISEInstanceItem.
I've been trying very to handle it. But - HOORAY - now got it. :D

I was searching a long time for a help file for LISELoader. But - mea culpa - I was searching in the instance module held, not in the module itself.

What I was always doing wrong with the Loader was the parameter value. In the field definition example template the value is given as value=$fielddef.value. A varaible instead of an alias.

But this I do possibly need only when I want display the chosen value of the field definition of the current instance, not the external.

Thank you. Now it is perfect.
antibart
Power Poster
Power Poster
Posts: 1155
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: Connecting an item with a detail view of a second instance

Post by antibart »

For other users who are also struggling a bit with Liseloader here is the solution a little more detailed.
velden wrote: Fri Oct 16, 2020 12:30 pm field definition in instance A of type: LISEInstanceItem.
In my case it's not neccessary to use LISE Instance Item.

Because I did not know about the help text in extensions->lise->module help->smarty plugins (I stupidly searched in the instance help) I had no exact idea how LIseLoader really work and did a lot of trial and error stuff based on examples I found in the comunities. But most of the examples uses LISEloader depending on "LISE Instance item" which misled me a little using the parameter "value" and "assign" correctly to display external field definitions.

Since I found the help file working with Liseloader is pretty easy. Here's the working code in the summary template of instance A:

Code: Select all

{LISELoader item='item' identifier='alias' instance='LISEInstanceB' value='item-alias-1' assign='count'}{if $count->fielddefs.counter ne '' && $count->fielddefs.counter ne '0'}+++Order now+++{/if}
So this was the sparking idea: ;)
velden wrote: Fri Oct 16, 2020 12:30 pm (read the LISE help)
Now I knew there must be a help file anywhere. I just had to find it. Thanks a lot.
antibart
Power Poster
Power Poster
Posts: 1155
Joined: Sun Aug 17, 2008 9:29 am

Re: LISE: Connecting an item with a detail view of a second instance

Post by antibart »

And as this solution would also work with a detail view of a second instance, I can mark this topic as solved. Thanks again for helping me to help myself.:)
Post Reply

Return to “Modules/Add-Ons”