Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
One-Page-Template-> automatically include new pages in a div
#26
(2014-11-19, 23:08:12)lesh Wrote: This is my variation of the Carlos script, tweaked to outputs only pages that are children of the current page and non-private. So pages can be automatically built from it's child-pages. Works fine for me, I use menu order for sorting and once the order is OK turn off "show in menu" to hide those pages from the nav menu.
...

Thanks Lesh, your script works great for creating the sub pages displayed within/below their parent page. Now all I need to do is find a way to not have to manually build the 'in-page' menus to link to anchors at the head of the sub-page sections. Any ideas?
Reply
#27
(2014-11-21, 17:59:42)davetest Wrote: Thanks Lesh, your script works great for creating the sub pages displayed within/below their parent page. Now all I need to do is find a way to not have to manually build the 'in-page' menus to link to anchors at the head of the sub-page sections. Any ideas?

I have wanted to solve this for ages and an "Auto sub-page-nav" was the other thing I had to do.

I have moved the part of the code that collects and sortds the pages outside the content section and added a loop to putput a list of links to the articles/subpages called "subnav".
which could be made a static block in a sidebar or top-bar using CSS.

PHP Code:
<?php     /* get the pages and sort them */
    
global $pagesArray
    
$pagesSorted subval_sort($pagesArray,'menuOrder'); // or 'title', 'menu', 'url', ...
    
$thisPage return_page_slug(); 
?>
    
<div id="container">
    <ul id="subnav"> <!-- fixed sidebar -->
        <li> <a href="#top">Top of Page</a> </li>
        <?php /* output a nav list for the subpages */
            
foreach ($pagesSorted as $page) if ($page['parent']==$thisPage && $page['private']!='Y') {
                
$pag $page['url']; ?>
                <li> <a href="#<?php echo $pag?>"><?php getPageField($pag,'menu'); ?></a> </li> 
        <?php ?>
    </ul>
    
    <main id="content" class="rowp">
    <a id="top"></a>
    <?php /* output the subpages as articles or sections */
        
foreach ($pagesSorted as $page) if ($page['parent']==$thisPage && $page['private']!='Y') {
            
$pag $page['url']; ?>
            <article class="subpage <?php echo $pag?>">
                <a id="<?php echo $pag?>"></a>
                <h2><?php getPageField($pag,'title'); ?></h2>
                <div class="subcontent">
                    <?php getPageContent($pag); ?>
                </div>
            </article>
        <?php ?>
    </main>        
</div> 

Also
There is a plugin in extend - SA TOC Anchors - that makes nav links to headings in the page.
Reply
#28
Thanks again Lesh, it works like a dream, but is there an easy way to put the contents of the submenu into the head of every sub page?
Reply
#29
Just to throw this out there, this kind of stuff might be doable in 3.4 with 1 or 2 lines of code, in case anyone isn't excited about it yet.

So make sure you post your function requests for filtering and sorting that you need to perform often or flow charts even.

for example

I want all the children of this page
but where
page is not private
and
contains these tags
and
is in the menu

And menu builders might be nice, nothing engineered for that yet though
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#30
(2014-11-23, 04:24:23)shawn_a Wrote: Just to throw this out there, this kind of stuff will be doable in 3.4 with 1 or 2 lines of code, in case anyone isn't exited about it yet.

I'm excited, bring it on, shawn_a = hero!
Reply
#31
Dave, you can use CSS to fix the postion of the nav or sub page nav to the top or side of the page eg. put it in a DIV above the regular page container - but after the php that finds and sorts the array.

CSS something like...
for the container of the sub-nav
#fixednav{position:fixed;top:0;left:0;width:100%;} /* stick to top of the screen and fill the width */

/* for the sub-nav ul */
#subnav{margin:0 auto; width:960px;} /* same as main page container */

the ul subnav will be centred inside the fixed container, stuck to the top of the screen.
you could do something similar with left:0 or right:0 to fix a sidebar;

for example ...this has a normal GS page nav with a sub-page nav underneath in a div fixed to the top of the screen
PHP Code:
<div id="fixednav">    
    <
nav>
        <
ul>
        <?
php get_navigation(return_page_slug()); ?>
    </ul>
    <ul id="subnav"> <!-- output subnav -->
        <li> <a href="#top">Top of Page</a> </li>
        <?php
                
foreach ($pagesSorted as $page) if ($page['parent']==$thisPage && $page['private']!='Y') {
            
$pag $page['url']; ?>
            <li> <a href="#<?php echo $pag?>"><?php getPageField($pag,'menu'); ?></a> </li> 
            <?php ?>
        </ul>
    </nav>
</div> 
Reply
#32
(2014-11-23, 04:24:23)shawn_a Wrote: Just to throw this out there, this kind of stuff might be doable in 3.4 with 1 or 2 lines of code, in case anyone isn't excited about it yet.

Sounds great. Kinda what I imagined getChildrenMulti() might do.

My own needs were to output the child pages and their fields and output them in a sorted order if not private. I didn't want/need the sub pages to appear in the main menu as in this they are only used as content blocks - so I used menu-order to arrange them then turned off 'show in menu'. I do use the menu text for the anchors.

As it stands GS + NewsManager do a pretty good job for me and the work yourself, Carlos and others continue to do on GS and it's complimentary parts is much appreciated. The Nivoslider plugin for 18n Gallery was pretty handy too.

I am playing with 3.3.4b and still excited by the tabbed options in the page editor.
Reply
#33
mvlcek has created a plugin that helps making one-page sites:
http://get-simple.info/extend/plugin/i18n-onepage/992/
Reply
#34
(2012-04-14, 19:42:59)Carlos Wrote: A way to have a one-page site with anchors (for GS 3.1):

Insert this code in your template (e.g. before, after, or instead of the <?php get_content(); ?> tag).
Code:
<?php
global $pagesArray;
$pagesSorted = subval_sort($pagesArray,'menuOrder'); // or 'title', 'menu', 'url', ...
foreach ($pagesSorted as $page) if ($page['url']!='index' && $page['menuStatus']=='Y') {
   $pag = $page['url'];
?>

<a name="<?php echo $pag; ?>"></a>
<div class="pagecontent <?php echo $pag; ?>">
   <h2><?php getPageField($pag,'title'); ?></h2>
   <?php getPageContent($pag); ?>
</div>

<?php } ?>

Thank you, this saved me

In my single page site I also need a redirect to external site for a couple of link, so my question is:
there is a way to add the function for checking if the keywords field on the page is empty or not? if is empty the variable ?pag is = to slug url , if is filled (with the url I need) the variable $pag is = at the content of the field

sorry for my bad english
Reply
#35
Try changing this:
Code:
$pag = $page['url'];
by this:
Code:
$pag = $page['meta'] == "" ? $page['url'] : $page['meta'];

[edit] But... this will not make any redirect. You should change the menu for that, not the content...
Reply
#36
Tried it right now

in my case doesn't work because of the javascript I use I need to add to links #!/ (es. <a href="#!/<?php echo $pag; ?>">

If I delete the #!/ it works


EDIT: I tried to add
Code:
$string = "#!/";
and modify your line like this
Code:
$pag = $page['meta'] == "" ? $string . $page['url'] : $page['meta'];

and seems to work fine

Thank you, I owe you a beer
Reply
#37
Why is there an exclamation mark there?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#38
I dont' know the reason
it's used by a javascript that show and hide the contents on a single page template of an existing website that I adapted to be used as a GS template
Reply
#39
Oh must be a template tag I thought that was the href #
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#40
Anyway, I remind that mvlcek created the OnePage plugin that helps creating one-page themes without requiring that special permalink structure, and lets you have normal pages too.
Reply




Users browsing this thread: 2 Guest(s)