I want to make a theme for a site which will have complex long page layouts, as is the fashion. so a page might have a full width banner and title then some full-width text then three columns of something punchy, then an article with a sidebar, etc. etc.. I thought I would achieve this in a flexible way by making main pages which contain their own child pages. Each child page would use a template - full width, 3 columns, left sidebar, whatever and I would build up the parent page like that. I have made a sketch, below.
So what would go in my template.php?
First the header with the menu of parent pages, then
get first child page content
get second child page content (if it exists)
get third child page content(if it exists).. and so on
Then the footer.
But what would the actual php code need to be? I don't think I would need page titles. I don't think I would need any child-menu or i18n plugin either. The parent pages wouldn't have any content of their own. I wouldn't need anchors down the page like a one-page site.
Not a feature request, but I need some help with rudimentary php. Is it as simple as I think?
(2014-02-05, 08:30:03)shawn_a Wrote: How many of these are you thinking of having, and how many content sections ?
IDK but let's guess up to six/eight main nav menu items/parents each made up of up to six/eight child-page blocks and I could make as many templates as I wanted with different columns, or with and without the page title, or for galleries or blog extracts.
It would end up like this page
http://wpexplorer-demos.com/thoughts/shortcodes/
Nice this is exactly what I want to be doable in gs, short codes for themes like bootstrap etc, cke styles never worked we'll I imagine widgets might be better. But simple short codes would be good enough.
I imagine you want the same thing but with static templates and contents for laypersons.
The only problem with using pages is how do you keep it organized, you need to have i18n just to collapse the pages view. And pages not in menu.
I think the better way would be if pages had multiple contents not one.
But then each content needs a title or id.
And how do we configure that, that is where categories come in, or perhaps we can parse them out of some definition in the template itself.
The template says I have these 4 contents and these are the ids.
Then page edit knows these depending on template selected.
A few more thin gs then need to happen aside from setting up the ckeditors or codemirrors or text areas somehow.
But the we will also have snippets and components, so maybe templates can register these as those and somehow tie them to pages.
This is all the direction I want gs to go in although the details are still pretty variable.
We also have to filter contents from page cache since they might be large.
I just looked at your drawing more closely, you are actually looking at something more modular that I was thinking by using pages as modules and templates as modules as we'll.
I think I have an idea.
Perhaps
Each template needs to know if it's in side another template, else it will include the header and stuff.
The template also needs to know when to load children as includes somehow.
The template also needs to have it own custom functions for getting page content when it is loaded as a module subpage
It also need a custom nav how do you determine which pages are subpages and not actual children for the menu.
Probably not menu checkbox alone, any ideas? Tags?
crude but i threw this together and it seems like it would work well.
You will have to figure out how to get the subpages of subpages, like for the multi column stuff, but it should work.
at the bottom of innovation template.php i stuck this , then had 2 children with 2 different templates ( whitout headers or footers or any of that jazz )
Excellent. I will see what I can do with it, but not this morning.
I wasn't really thinking about GS development, just how to approach a job I need to do. Carlos had once given us a bit of code to make a single page site and I was thinking what I need is like each page as a single page site, made up of page-blocks each on a different template.
The content for sidebars and multi-columns I can do with components or tabs as normal.
Have made a fine theme with the code you gave above and it works a treat. Complex, modular multi-column layouts all through the back end without editing templates.
The only problem I have is that I have no control of the order of the sub-pages other than changing the slugs - they appear in alphabetical by slug order afaict. I will upload when I have finished testing.
I am trying to do the same conditional php for getPageContent as I have done with get_component so I need something like
PHP Code:
if (getPageContent('sidebar')): getPageContent('sidebar'); else : echo('<h2>Sidebar</h2><p>Make a page with the slug \'sidebar\' and write in it whatever you want</p>'); endif;
but that gives me both the PageContent and the echo. What should I be writing?
returnPageContent, but you should not run it twice cause it runs filters, use a tmp var
of course if you just need to check if it exists its easier to check pagesArray if you are not sure it exists, cause it will throw errors if it dues not.
I am still working on this. It gets pretty confusing when I use getPageContent for small editable blocks - it means that I am using GS Pages as proper pages, as parts of pages and also as parts of parts of pages.
Not certain for the moment that my first version which just used includes to build custom template files wasn't the most practical.
and it works fantastic except for one situation: if you have only one child page I get a warning: Invalid argument supplied for foreach(). Is it possible to fix that and to show only child pages that are public and hide private pages?
Thank you for your help.
Edit: After searching the forum again, I found this solution which is what I needed: