Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sub-pages into one page
#1
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?
Reply
#2
How many of these are you thinking of having, and how many content sections ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
(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/
Reply
#4
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.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
I know this does not help your current situation.
And components probably won't work since you would have so many.

And you do not want to rely on special pages or simple tabs or custom fields plugins?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#6
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?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#7
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 )

template.php
PHP Code:
<?php
       define
("IN_SUB",true);
     
$page get_page_slug(false);
     
$children getChildrenMulti($page,array('template'));
     foreach(
$children as $child){
         
$template $child['template'];
         
$page $child['url'];
         if(
$template!='template.php') include($template);
     }
?>

template_sub_1.php
PHP Code:
<?php if(!defined('IN_GS') or !defined('IN_SUB')){ die('you cannot load this page directly.'); } 

echo 
"<HR>".__FILE__;
echo 
'<h2 style="margin:10px;border:1px solid #00FFFF">TEMPLATE SUB 1</h2>';

GLOBAL 
$page;
getPageContent($page);

?>

You also might want to have these sub pages redirect somewhere if not called via an include ( use a global to set and check )
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
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.
Reply
#9
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.


Attached Files Thumbnail(s)
   
Reply
#10
And it's responsive, too.
Reply
#11
You can probably get them in order of menu, using the menudata or some other function.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
actually you can probably just do
PHP Code:
$children getChildrenMulti($page,array('template','menuOrder')); 

Then subval sort it by menuOrder


PHP Code:
$page get_page_slug(false);
    
_debugLog($page);
    
$children getChildrenMulti($page,array('title','template','menuOrder'));
    
_debugLog($children);    
    
$childrenSorted subval_sort($children,'menuOrder');
    
_debugLog($childrenSorted); 

works for me
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
your slug names seem confusing fyi

somethnig like
2col-a
2col-b

4col-a
module-a

or section1a

might be easier

( I meant component slugs )
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#14
Question:

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?
Reply
#15
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.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#16
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.
Reply
#17
shawn_a, thank you very much for this function. This is so helpful!

I use your code

PHP Code:
<?php
     define
("IN_SUB",true);
 
    $page get_page_slug(false);
 
    $children getChildrenMulti($page,array('title','template','menuOrder'));
 
    $childrenSorted subval_sort($children,'menuOrder');
 
    foreach($childrenSorted as $child) {
 
        $template $child['template'];
 
        $page $child['url'];
 
        if($template!='template.php') include($template);
 
    }
?>

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:

http://get-simple.info/forums/showthread.php?tid=3081

However, thank you for your kind support.
Reply




Users browsing this thread: 1 Guest(s)
Free HDTV Channels Residential Solar Panels