Page 1 of 1

Get Parent pages / child page content in Bludit 2.0

Posted: Wed Oct 18, 2017 2:29 pm
by VanHalen
I'm currently updating (locally) a website for a client which runs on Bludit 1.4.

The update went ok, no real issues in the backend. on the frontend all custom functions stopt working as expected. In the past i used a function like below, to get child page content and output custom menu's, page content, etc:

Almost everything depended on, $pagesParents[NO_PARENT_CHAR];

Code: Select all

function getSubPage($name, $title=true) {
	
	global $Page, $pagesParents;

	$parents = $pagesParents[NO_PARENT_CHAR];
	
	foreach($parents as $parent):
	
		if( $parent->published()):
	
			if(isset($pagesParents[$parent->key()])):
	
				$children = $pagesParents[$parent->key()];
	
				foreach($children as $child):
					if ($child->slug()!=$name):
					elseif($child->slug()==$name && $title):
					   echo $child->title();
					   echo $child->content();
					endif;
				endforeach;
		
			endif;
		endif;
		
	endforeach;
}
What is the right way to get child content, page titles, etc. in Bludit 2.0? I'm currently looking in to getParents(), getStaticDB() But the page title is not present in the Array output of these functions.

Is there another way to do this? Or does anyone know how to update the code above?

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 1:05 pm
by Torsten_Kelsch
I think child pages are not available in Bludit 2.0 at all, see my post viewtopic.php?f=6&t=1006. Only posts (now called published) can be cascaded, not pages (now called static). That does not make sense to me and is not the usual behaviour of content management systems.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 1:30 pm
by VanHalen
Mmmm, thats not good news if true.

There is a way to do it, but i don't want to load the complete content for all pages, just to find the page title.

That's bloated in my opinion, since i only need the page/content (what is it called now?) ID or title and then decide if want to load the content or use it for a custom menu layout.

If this (still) exists i have no problem dividing content and displaying it where i want it. I would use static as content snippets on a content page to display extra info and use content with a special category for blog posts, etc. but overall the backend could use a better way for dividing content, 1-100 pages would eventually not work.

Many things changed since my last visit, 1.4 but i do not need to update if it's not possible anymore, but will move new projects which could run on Bludit to another cms.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 1:47 pm
by Torsten_Kelsch
You could upgrade to version 1.6.2 (https://github.com/bludit/bludit/releases/tag/1.6.2), which is still available and should work without any issues.

In version 2.0, everything is called content, there is no more difference between pages and posts, technically. Content can be saved as static or published, which is similar to pages and posts in the 1.x versions, if you like. The programming is easier, as Diego and Edi say.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 1:57 pm
by VanHalen
Thanks for the info.

I need to inspect this 'new way' more before condoning it as something i cannot use.

And maybe i find a way around it for the 'old' 1.4 website. The Bludit API could do it, so that could be the solution for updating to 2.0 eventually.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 4:27 pm
by Edi
Torsten_Kelsch wrote: Thu Oct 19, 2017 1:05 pm I think child pages are not available in Bludit 2.0 at all, see my post viewtopic.php?f=6&t=1006. Only posts (now called published) can be cascaded, not pages (now called static). That does not make sense to me and is not the usual behaviour of content management systems.
You are thinking to complicated!

Bludit 2 uses content, that can be used for blogs (ordered by date) and websites (ordered by position) and blogs with pages (content ordered by date and static content). Content ordered by date can have parents/child. For static content it is at the moment not yet possible. But I think this could be done easily.

There is nothing like a usual behaviour of a CMS. Every CMS has is own structure and terminology. Also it makes no sense to mix up systems for blogging and content management. With Bludit 2 you can decide to have a blog or a CMS. In addition to this you can have a blog with static content or static content with a blog.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Thu Oct 19, 2017 4:51 pm
by Edi
VanHalen wrote: Wed Oct 18, 2017 2:29 pm In the past i used a function like below, to get child page content and output custom menu's, page content, etc:
Where do you use the code? In a plugin?

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Fri Oct 20, 2017 2:52 pm
by Torsten_Kelsch
There are some clarifications: viewtopic.php?f=13&t=1016. In short: Published content can be sorted by date or by position and can have sub content. Static pages can’t have sub pages at the moment, but as Edi told me, this is only a bug and will be fixed. So, let’s simply be patient, everything will turn out fine.

Re: Get Parent pages / child page content in Bludit 2.0

Posted: Sat Oct 21, 2017 3:07 pm
by diego
Hi VanHalen,
I use similar case for the documentation, https://docs-v2.bludit.com/en/

Take a look at the sidebar
https://github.com/bludit-themes/docs/b ... idebar.php

Here is a list of `"content" global variables you can use, there are some comments there and who they are defined.
https://github.com/bludit/bludit/blob/m ... .pages.php

Here is a little code you can try

Code: Select all

<?php

foreach ($pagesByParent[PARENT] as $Parent) {

	// $Parent is a Page Object
	echo 'Parent title' . $Parent->title();

	// Check if the parent has sub-pages/children
	if (!empty($pagesByParent[$Parent->key()])) {

		// Foreach sub-page/children
		foreach ($pagesByParent[$Parent->key()] as $Child) {

			// $Child is a Page Object
			echo 'Child title' . $Child->title();
		}
	}
}