Page 1 of 1
LISE fielddef Content Pages stores id -> frontend id2title ?
Posted: Fri Mar 18, 2016 4:41 pm
by eus
Hi,
Does anyone know how i can get (for example) the menutag or title from content pages in the LISE summary template (if you choose field content pages it gives a dropdown of all pages and stores the id of that page). That's perfect but a then want a field shown from that page in the listing like title or menutitle.
Is there a core function for this or do i have to make an udt and sign it back with smarty ?
Thnx
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Fri Mar 18, 2016 4:53 pm
by Jeff
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Sat Mar 19, 2016 2:41 pm
by eus
Hi,
Ik know page_attr but that's an option for getting content out of the current page. Not what i need.
Example in summary lise template... something like this
{foreach ...}
{$pageidfield from lise} - {other $fieldfromlise}<br>
{/foreach}
will show for example in the frontend
39 - title1
41 - title2
52 - title3
to
{foreach ...}
{get menu title from cms page via $pageidfield} - {other $fieldfromlise}<br>
{/foreach}
So i want the numbers replaced by the menudescription of pageid 39 etc..
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Sat Mar 19, 2016 3:16 pm
by Jeff
Did you actually read the help for the tag?
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Mon Mar 21, 2016 8:03 pm
by eus
Of course ...
http://docs.cmsmadesimple.org/tags/cmsms-tags/page_attr
But that is for the page itself not in a foreach loop. There was no option like {page_attr pageid=39 key="extra1"} or i am missing something.
It's only for LISE -> summary template in combination with Contentpages when you want some page information in the foreach loop.
I solved it this simple way to add a pointer array in the template.
UDT example menutext
=========
$db = cmsms()->GetDb();
$query = "select content_id,content_name, content_alias, menu_text from cms_content where template_id = 35";
$result = $db->Execute($query);
$menutext= Array();
while ($result && $row = $result->FetchRow())
{
$menutext[$row['content_id']] = $row['menu_text'] ;
}
$smarty->assign('menutext', $menutext);
=========
{menutext} creates array $menutext['cmspageid'] = "the menutext from that page. The "where" in the sql above is only specific for me.
So it's just a fix with only one db call.
Open the LISE summary template and add {menutext} (or any name you want) on top. You can also assign the content_alias or content_name etc.
In my case the "content pages" field named "categorie".
Then change the field where the page id is stored (Content Pages) from {$item->categorie} to {$menutext[{$item->categorie}]}.
Now it shows the menutext from that pageid in the summary template.
Example...
{foreach from=$items item=item}
<span class="verslag-title">
<a href="{$item->url}" title="{$item->title}">{$menutext[{$item->categorie}]} - {$item->title}</a>
</span>
... etc
{/foreach}
So this works for me.
It's only for LISE -> summary template in combination with Contentpages when you want some page information.
I think i can mark this as solved ... ok ?
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Mon Mar 21, 2016 8:19 pm
by velden
In CMSMS 2.x this tag has the 'page' parameter. You can use the page ID.
It's in the help of the tag in the CMSMS installation.
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Mon Mar 21, 2016 9:13 pm
by eus
Hi,
Yes you're right i missed that one..
(optional) page (int|string) - An optional page id or alias to fetch the content from. If not specified, the current page is assumed.
{page_attr key="title" page="39"} works but ...
It hasn't some page fields i needed like menu_text. But it's usable for other solutions. In a foreach loop it wil call 20x the db (with 20 entries). In my solution only one so i keep the simple workaround.
Thanks for the help
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Thu Apr 14, 2016 1:58 pm
by pedes
I have the same problem...
I have the page ID coming from the LISE content-pages field definition.
But I would like to have the alias of the page
{page_attr key="alias" page="39"} or
{page_attr key="page_alias" page="39"}
is not working
How can I get the alias from a page if I have the page ID ?
Thanks for any help
Kind regards
Peter
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Thu Apr 14, 2016 7:24 pm
by velden
Could you provide an example of what exactly you would like to accomplish? Maybe someone comes up with another approach/solution.
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Fri Apr 15, 2016 9:14 am
by pedes
I'm using LISE.
Here I have a a field definition 'content pages'.
This output the content pages id. But I need the alias for that id.
I have in LISE a list of videos (youtube number, title and discription).
Some video's need to be show on the same content page others on other content pages. There for I have the selection content page, so I can tell on what page they belong to.
I use also the category definition to tel where they can be post (on what page), in the page template i call the LISE instance whith the catgory als the alias from that page.
it is hard to explain on text
So to be short...
I have list of youtube movies that need to show on pages, some pages will have 1 movie others will have 3 or more movies, so in the LiSE summary I need to group them en show them on the correct page.
Kind regards
Peter
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Fri Apr 15, 2016 9:55 am
by velden
I think I would try to find another approach (use the data you do get by default).
But this UDT might be useful (didn't test it very well):
Code: Select all
if (isset($params['page_id'])) {
$page_id = $params['page_id'];
} else {
echo 'page_id parameter must be set';
return false;
}
if (isset($params['assign'])) {
$assign = $params['assign'];
} else {
echo 'assign parameter must be set';
return false;
}
$alias = false;
$hm = cmsms()->GetHierarchyManager();
$node = $hm->find_by_tag('id',$page_id);
if ($node) $alias = $node->get_tag('alias');
$smarty->assign($assign,$alias);
Example usage:
Code: Select all
{get_alias page_id=10 assign=palias}
alias: {$palias}<br>
I'm a little worried about efficiency when calling this UDT numerous time to get the same alias many times.
Re: LISE fielddef Content Pages stores id -> frontend id2tit
Posted: Fri Apr 15, 2016 7:05 pm
by Jeff
I am not seeing the reason why you need the page alias.
pedes wrote:I'm using LISE.
Here I have a a field definition 'content pages'.
This output the content pages id. But I need the alias for that id.
I have in LISE a list of videos (youtube number, title and discription).
Some video's need to be show on the same content page others on other content pages. There for I have the selection content page, so I can tell on what page they belong to.
I use also the category definition to tel where they can be post (on what page), in the page template i call the LISE instance whith the catgory als the alias from that page.
it is hard to explain on text
So to be short...
I have list of youtube movies that need to show on pages, some pages will have 1 movie others will have 3 or more movies, so in the LiSE summary I need to group them en show them on the correct page.
Kind regards
Peter