Forum

Thread tagged as: Question, Meta

HowTo: reuse page region fields in navigation (one pager)

Hi,

I'm a perch newbie, apologies for redundancy or missed RTFM.

Layout / Setup

  • One Pager Design with a handful of sections
  • Each section is setup as a perch region
  • There are two navigations (one header and one in the banner area)

The basic idea is to have anchors for each page section and the two menus pointing to these anchors. I would like the user to manipulate the menus by simply editing the regions themselves and avoid to manage two extra regions for the menus (which would mean updating/creating each section name thrice).

To achieve this, I think (currently;) the best approach with perch would be to use fields of the regions and reuse them when in the menus.

In the control panel, the navigation options would show up as fields on the regions: * Menu Label (e.g. "About Me" * Section Slug (e.g. "about")

How would I implement this? Or, did I missunderstand some fundamentals?

I searched the docs and the forum and it seems my domain vocabulary for perch is not yet sufficient enough to find an answer for this question.

Thanx in advance! --voko

Volker Kopetzky

Volker Kopetzky 0 points

  • 6 years ago

I think blocks is the best solution. Then a second template extracting the labels from each block to create a navigation using perch_content_custom().

Robert,

thanx for the fast reply.

As I'm still learning, would this be the correct start?

file: index.php

(...)
<php perch_content("main") ?>

file: main.html

<perch:blocks>

<perch:block id="navtop">
    <perch:template path="content/blocks/navtop.html" />
</perch:block>

<perch:block id="navbanner">
    <perch:template path="content/blocks/navbanner.html" />
</perch:block>

<perch:block id="sections">
    <perch:template path="content/blocks/sections.html" />
    <!-- sections.html contains several sections, with each section being referenced by nav*.html -->
</perch:block>

</perch:blocks>

Next Question

How would I access field values defined in sections.html from navtop.html ?

Is there a code base with examples?

What's your navtop.html look like?

I am headed out to work, so I will check on this thread in about 10 hrs.

Hi Robert,

no sources yet - and I'll be offline for today and tomorrow. Will work on this Thursday and reply back with my files then (still gotta do some more learning ;).

Thanx!