Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
One-page site with anchor links
#1
(This was previously posted here.)


A way to have a one-page GetSimple site with anchor links (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 } ?>
Edit what you need to customize the output (remove the <h2> line if you don't want titles, etc.)

Then go to Admin > Settings and set your Custom Permalink Structure to:
Code:
#%slug%

All pages (but index) that have been added to the menu will be displayed in the home page.

The div's will have class="pagecontent SLUG" so that you can style them (of course you can edit that in the script, if you don't want it this way)
Reply
#2
Hi the code you supplied works well expect how do custom fields get displayed?

All attempts to call my custom fields fail even through they are stored in the page XML.

Cheers
Adam
Reply
#3
I suppose that get_custom_field('fieldname') will not work with this kind of site. It may work by using getPageField($pag,'fieldname') instead.
Reply
#4
Nice! It works good but, i dont understand how to add scrolling effects for example, for move the page to the slug...
Any idea?
Reply
#5
A better solution:
http://get-simple.info/extend/plugin/i18n-onepage/992/
Reply




Users browsing this thread: 1 Guest(s)