Jump to content

repeatable page elements -- how do you approach it?


evan
 Share

Recommended Posts

Hi all,

I just discovered Processwire and am very intrigued as a current Textpattern user, and seeing the similarities and new possibilities.  Quick question -- how do you all manage your repeatable page elements that contain Processwire variables (called forms in TXP)?  By "repeatable page elements" I mean formatted content like blog entries, calendar events, etc. within a greater page layout.

I realize this is outside the scope of Processwire itself, and more on the personal workflow side, but I'm curious to see what methods people use before I start building.  Do you store them in a PHP include as variables?  Functions?  A combination of both?  I'd like to hear how people typically approach this, and why.  Thanks!

-evan

Link to comment
Share on other sites

I should probably clarify that I'm interested in methods to abstract these elements outside of the templates, so I can reuse them.  Perhaps I'm overthinking it...do people just do something like this?

blog_entry.inc:

function blog_entry_markup ($x) {
echo "<strong>$x->title</strong><br />$x->body";
}

blog_template.php:

include('blog_entry.inc');
foreach ($page->children as $child) {
blog_entry_markup ($child);
}
  • Like 1
Link to comment
Share on other sites

Very much like that. I have common includes (/templates/includes/common.inc) where I keep my most used functions (ie. renderList, renderItem) which can be used with almost any kind of content (blog posts, news, events etc..). I have some more spesific functions also (like renderCalendar etc) which require some spesific kind of content (like event here). I currently keep them in same file, but I might put those as separate file (like events.inc).

  • Like 1
Link to comment
Share on other sites

Cool, another TXP user :-)

An .inc file (or .inc.php) is the direct analog to a Textpattern form. The main difference being that TXP stores forms (i.e. partials) and page templates in the database, and ProcessWire stores them as files.

So for example:

<txp:output_form form="sidebar_gallery" />

Would typically be like this in ProcessWire:

<?php include('sidebar_gallery.inc'); ?>
Link to comment
Share on other sites

Great, glad to know I'm on the right track!  I see some nice organizational possibilities using associative arrays or classes/objects to store markup.  Thanks for the responses, I'm stoked to implement a site with PW now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...