#1 2014-06-18 09:52:57

leonaze
Member
Registered: 2013-10-08
Posts: 17

Get main parent page ID in article view

Hi,

Is someone try to get this ? I need to get the ID of the main page of an article.

Thanks for the help.

Offline

#2 2014-06-19 03:06:52

ukyo
Community Manager
From: Marmaris - Turkey
Registered: 2010-05-19
Posts: 734
Website

Re: Get main parent page ID in article view

There must be a tag for get parent page data :
Like this (Can you try it) :

<!-- Get the first parent page -->
<ion:page parent="true">
  <ion:title/> : <ion:url />
</ion:page>


<ion:page parent="-1">
  <ion:title/> : <ion:url />
</ion:page>

<!-- Get the grand parent page -->
<ion:page parent="-2">
  <ion:title/> : <ion:url />
</ion:page>

<ion:ukyo from="Turkey" />
Ionize CMS Türkçe Dil Çeviri Dosyaları | My Github Repositories
Please send your first message to a forum section, not forum users or administration.

Offline

#3 2014-06-19 06:57:56

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: Get main parent page ID in article view

@leonaze

Hi,

You need to give a context, else the problem may be misread.

Please post the code your using to get the article.

In general, you would use <ion:articles> type iterator, for which @ukyo mostly answered - just use <ion:page> tags, such as <ion:page:id/> directly (see http://doc.ionizecms.com/en/tags-reference/page-tags)

Other than that, you could use <ion:trace/> then retrieve the right key usign <ion:get key=''> type tags in most cases (see http://doc.ionizecms.com/en/tags-reference/special-tags)

If your affecting the admin panel, totally different - as is if your using ajax or some exotic method of your own.

Context is everything


Webmaster | OneCNC Australia

Offline

#4 2014-06-19 11:05:29

leonaze
Member
Registered: 2013-10-08
Posts: 17

Re: Get main parent page ID in article view

Thanks for your answers.

To be more precise, it's an event agency site, I have sectors of activities pages which contains event articles attached and a home page where I also attached all event articles. So an event article is main attached to his sector page and the home page.

I use this code in the home page :

<ion:page:articles type="events">
<ion:article>

	<div class="evenement">
		<a class="link_event" href="<ion:url />">
			<ion:medias type="picture" size="149,149" method="adaptive" limit="1">
			<img class="grayscale" src="<ion:media:src />" alt="<ion:title />" />
			</ion:medias>
		</a>
		<div class="survol_evenement">
			<h3><ion:title /></h3>
		</div>
	</div>
	
</ion:article>
</ion:page:articles>

I want to add a class to the survol_event to add a background color for the specific sector.

But the ukyo solution don't work, nothing return. When I use <ion:trace /> I saw "[main_parent] => 0" because home page isn't the main parent page.

I need main parent page ID or path to add a class.

I hope it's a little bit more clear for you.

Thanks.

Offline

#5 2014-06-20 04:01:57

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: Get main parent page ID in article view

So you have articles which appear in 2 locations - ie. have 2 parents - and you want to get the OTHER parent_id?

I cant see anything in standard <ion:trace/> that would answer that particular situation.

You would prob have to extend /application/Libraries/Tagmanager/Article.php to answer that, maybe add a new article tag. There are some other topics regarding that, some of which ive posted old code in and some i used to help make that code, but you need passing knowledge of php and maybe to extend Tagmanger.php itself a little too...

Other solutions may be something like using ajax to load content (which could help improve user experience, though still need passing php and some ajax experience, though again some good posts around).

In my own case, i never use 'multiple parents', instead in the few cases i use this i just use the <ion:page:articles> or <ion:page> wrapper with 'id="x"' and a filter to load all articles of a type from specific pages (maybe you can make that work with multiple pages)

Summary
Basically, from what i can see if you really want to use this kind of structure, you better off using some other conditional like article_type or even extended fields or elements, and use that to determine special classes.

Other than that your looking at customizing tag library, which issnt too hard really but does take a bit of php knowledge and tinkering, especially if first time, as i also think you may need to add that column to the core sql query to build articles (so maybe just article_model...)

Or step back from main_parent_page_id type of deal and think of other conditions to check, preferably ones that already show in <ion:trace/> wink

Hope this helps smile


Webmaster | OneCNC Australia

Offline

#6 2015-10-30 13:40:38

fredericomarinho.com
Member
From: Juiz de Fora / Brazil
Registered: 2015-06-08
Posts: 40
Website

Re: Get main parent page ID in article view

Hello leonaze! Could you get the main page ID? I need this too! Thanks!


Frederico Marinho - Social Media and Web Developer
contato@fredericomarinho.com
fredericomarinho.com

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations