Documentation for Mark Huot’s Pages Module.
The beauty of this module is that you can create seemingly/endless/url/structures/that/go/on/and/on from a single template and have breadcrumbs > that > follow > it > to > the > end. throw into this a dynamically produced menu and you have something pretty special. Hats off to Mark.
Step 1: Backup your database.
Ok, Grab the zip file from the first post and copy to your site, install the module and enable the extension. If you can’t do this i’d probably get some more ee experience first before proceeding… Turn off Auto Category Parents in your weblog preferences.
Create a weblog called Content (for example), and then create a new template which calls up your {defined_fields} (See reference code below). You’ll also need to create a category group and assign it to the weblog. This category group should reflect the structure of the pages you want.
ie:
Home
Meet the team
—Staff 1
—Staff 2
Contact
then go to Modules > Pages > Configure Pages in the CP. Assign the weblog Content, and select the template you created as the pages template. Hit the giant SAVE button at the bottom.
Then go to Modules > Pages and you should see a structure of pages like the above. (If you’re not seing a list of pages here and are taken to the Configure Pages page, you haven’t assigned the content category group to the content weblog). Click on each of the pages and enter some content to each one. (Marks suggestion of adding a new tab called pages to act as a quick link to the module is great)
Ok, we’re almost done. Just need to throw in some slightly different exp:weblog code into your template to get this working.
————————————
REFERENCE CODE:
————————————-
Pulling up content in the template:
—————————————————————————————
{exp:weblog:entries category="{static_page}" dynamic="off"}
{summary}
{body}
{any_custom_field_you_like}
{/exp:weblog:entries}
Note the dynamic=“off”, this had me banging my head off the wall for a day or two. Also tags such as entry_id=“x” disable=“x” work like the regular weblog tag so feel free to use those.
Breadcrumbs
—————————————————————————————
{exp:static_page_path backspace="0"}<a href="{url_title}" title="{title}">{title}</a> | {/exp:static_page_path} {exp:weblog:entries category="{static_page}" dynamic="off" weblog="content"} {title} {/exp:weblog:entries}
Menu
—————————————————————————————
{exp:static_page_path direction="post"}<a href="{url_title}" title="{title}">{title}</a>{/exp:static_page_path}
The menu has a couple of variables:
{exp:static_page_path direction="post" page="13"}
{exp:static_page_path direction="post" depth="1"}
{exp:static_page_path direction="post" nest="false"}
the default menu is displayed as an unordered list with hierarchy identical to that of your pages configuration/categories. This will produce a flat list.
You can use combinations of the above together no problem.
Static Page Conditionals:
—————————————————————————————
Much like using segments, this conditional checks to see which static page is being rendered.
{if static_page_name == "services"}
...replace with your content...
{/if}
{if static_page_name == "about_us"}
...replace with your content...
{/if}
Workaround for getting back Segments:
—————————————————————————————
This is a response from wazdog regarding this workaround for not being able to use segment variables. This version doesn’t require using php in your templates. You’ll need to update your path.php file with the following. Be sure that you preserve any additional $global_vars you’ve created back into this array.
$segs = explode("/", $_SERVER['PATH_INFO']);
$global_vars = array(
"seg_1" => $segs[1],
"seg_2" => $segs[2],
"seg_3" => $segs[3],
"seg_4" => $segs[4],
"seg_5" => $segs[5],
"seg_6" => $segs[6],
"seg_7" => $segs[7],
"seg_8" => $segs[8],
"seg_9" => $segs[9]
); // Last entry must not include the comma at the end
The $segs variable that comes before the $global_vars array is crucial! Be certain to add it in. Now you can use {seg_1} in place of {segment_1}. Even in “if” statements, such as:
{if seg_1}{/if}
or
{if seg_1 == "news"}{/if}
It’s still a workaround, but it’s easier than the earlier php workaround…
Fixing your search results
—————————————————————————————
The links to your static pages on the search results page will break, you’ll need to wrap the following code around your search results template:
{exp:pages_results} {/exp:pages_results}
for example:
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
{exp:pages_results}
<tr>
<td class="{switch}" width="20%" valign="top"><b><a href="{auto_path}">{title}</a></b></td>
<td class="{switch}" width="80%" valign="top">{excerpt}</td>
</tr>
{/exp:pages_results}
{/exp:search:search_results}
As you get more comfortable with this, you can create templates for specific pages and assign them via the Configure Pages page.
Pagination problems:
—————————————————————————————
Problem: pagination doesn’t work in exp:weblog:entries because it’s no longer acknowledging the P0/P5 etc segment of your url on subsequent pagination-generated pages.
Solution: (From Mark) I’ve gotten around ... by using physical templates where pagination is needed. For example if I had a static page at /blog/archive, i would create a template group “blog” and template “archive”. Then instead of using the Pages template you will see the physical template. The only difference here is that you’ll have to hardcode the category ID into the {exp:weblog:entries /}
Tips:
—————————————————————————————
When copying and pasting code from this forum, double check your quote marks, sometimes they are italicized..
Use the View Page link in the module to browse to your pages when testing, the URL structure is not conventional EE stuff. Especially if you have a deep hierarchy of pages.
Creating new pages isn’t that simple for clients to grasp, so I’d suggest this would be applied to sites where the content structure is quite fixed and only updates are carried out by the client.
Enable the extension.
Deactivate auto category parents
Admin › Weblog Administration › Global Weblog Preferences > Auto-Assign Category Parents > No
Did i say Enable the extension.?
URL Segment variables don’t work as expected…
Template group and template names are not contained in the urls. Pages uses your page hierarchy created by your categories for generating the url.
Probably best not to conflict Template Groups with Pages/Categories. ie if you have a template group called home, dont name a page home as they both will have the url index.php/home. (I’m not sure which one comes out top)
======================================
Hope this helps some of you, I’m in a bit of a hurry so let me know if I’ve missed anything obvious…
cheers,
Iain.
