Internal Page Link > Access specific content blocks

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Internal Page Link > Access specific content blocks

Post by naturelab »

I am trying to use either method below to get the Gallery assigned to a particular page.

Code: Select all

{page_attr page=$child.alias key="Gallery" assign='projectgallery'}
or

Code: Select all

{$projectgalleryf=cgsimple::get_page_content($child.alias,'Gallery')}
If the page type is 'content' this works fine, I use this all the time. However, if the page type is 'Internal Page Link' it doesn't seem to work.

How do I access the page specified in the Internal Page Link, ie: the destination link.
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Internal Page Link > Access specific content blocks

Post by naturelab »

Also, how do I check the content type of the page ? :-
Something like...

Code: Select all

{if content-type == 'inernallink'}Do something{/if}
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Internal Page Link > Access specific content blocks

Post by Jo Morg »

As for your 1st question: Internal links don't have a content, however they do have a property that you may access (although undocumented...) so you should be able to do something like this:

Code: Select all

{page_attr page={page_attr page=$child.alias  key='page'} key='_dflt_' assign=projectgallery}{eval var=$projectgallery}
However you'd need to make sure that "$child.alias" is an internal link...

As for your 2nd question:

Code: Select all

{if $content_obj->Type() == 'pagelink'}Do something{/if}
The code may need a few tweaks to adapt to your use but the concept does work - I have tested it.
"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!
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Internal Page Link > Access specific content blocks

Post by naturelab »

Thanks Jo ! We love the undocumented properties !

So I am looping through a the child pages of a top level section, tryng to get the gallery from each ( some of the children are content pages, some are internal links.

Does this look right ?

Code: Select all

<!-- Display ALL children ( some are Internal Links ) -->

{$children=cgsimple::get_children()}
{foreach from=$children item='child'}
{$parenttitle=cgsimple::get_root_alias($child.alias)}
{$projecttitle=cgsimple::get_page_title($child.alias)}
{page_attr page=$child.alias key="Gallery" assign='projectgallery'}
{page_attr page={page_attr page=$child.alias  key='page'} key='_dflt_' assign=internallinkprojectgallery}

<div class="element-item col-xs-6 col-sm-3 col-lg-3">
<h4 class="summary"><a href="{root_url}/{$parenttitle}/{$child.alias}/" title="{$projecttitle|escape:html}">{$projecttitle}</a></h4>
{Gallery dir={if $content_obj->Type( $child.alias) == 'pagelink'}internallinkprojectgallery{else}$projectgallery{/if}  number="1"  template="gallery_small" }
{/if}
</div>

{/foreach}
This bit doesn't seem to work. What am I doing wrong ?

Code: Select all

{if $content_obj->Type( $child.alias) == 'pagelink'}I am internal{/if}
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Internal Page Link > Access specific content blocks

Post by Jo Morg »

naturelab wrote:This bit doesn't seem to work. What am I doing wrong ?

Code: Select all

{if $content_obj->Type( $child.alias) == 'pagelink'}I am internal{/if}
Nope that won't work: {$content_obj} always refers to the current page content object. For the use you are after, and since you have CGSimpleSmarty you should be able to use:

Code: Select all

{if cgsimple::get_page_type($child.alias) == 'pagelink'}I am internal{/if}
"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!
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Internal Page Link > Access specific content blocks

Post by naturelab »

Thanks again. Nearly there, but not quite... updated code :-

Code: Select all

<!-- Display ALL children ( some are Internal Links ) -->

{$children=cgsimple::get_children()}
{foreach from=$children item='child'}
{$parenttitle=cgsimple::get_root_alias($child.alias)}
{$projecttitle=cgsimple::get_page_title($child.alias)}

{if cgsimple::get_page_type($child.alias) == 'pagelink'}
{page_attr page={page_attr page=$child.alias  key='page'} key='_dflt_' assign=projectgallery}{eval var=$projectgallery}
{else}
{page_attr page=$child.alias key="Gallery" assign='projectgallery'}
{/if}

<div class="element-item col-xs-6 col-sm-3 col-lg-3">
<h4 class="summary"><a href="{root_url}/{$parenttitle}/{$child.alias}/" title="{$projecttitle|escape:html}">{$projecttitle}</a></h4>
{Gallery dir=$projectgallery  number="1"  template="gallery_small" }
{/if}
</div>

{/foreach}
This bit in bold doesn't seem to work (yet)

Code: Select all

{page_attr page={page_attr page=$child.alias  key='page'} key='_dflt_' assign=projectgallery}{eval var=$projectgallery}
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Internal Page Link > Access specific content blocks

Post by naturelab »

Works now ! Thanks

Code: Select all

{page_attr page={page_attr page=$child.alias  key='page'} key='Gallery' assign=projectgallery}{eval var=$projectgallery}
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Internal Page Link > Access specific content blocks

Post by Jo Morg »

Yup, key='Gallery'... I had no way to know it that was a valid content block or not... _dflt_ is the default content...
Glad I could help.
"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!
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Internal Page Link > Access specific content blocks

Post by naturelab »

Cheers Jo ! Sounds dumb, but how do I mark this thread as [solved] ? I can never figure it out !
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Internal Page Link > Access specific content blocks

Post by Jo Morg »

Just click the green tick of the post that offered the correct answer (or any other for that matter) :).
"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!
Locked

Return to “CMSMS Core”