evan Posted November 26, 2011 Share Posted November 26, 2011 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 More sharing options...
Nico Knoll Posted November 26, 2011 Share Posted November 26, 2011 Just as subpages with an blog template which contains fields like title, body, tags, category, etc. I guess... Link to comment Share on other sites More sharing options...
evan Posted November 26, 2011 Author Share Posted November 26, 2011 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); } 1 Link to comment Share on other sites More sharing options...
apeisa Posted November 26, 2011 Share Posted November 26, 2011 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). 1 Link to comment Share on other sites More sharing options...
MarcC Posted November 27, 2011 Share Posted November 27, 2011 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 More sharing options...
evan Posted November 27, 2011 Author Share Posted November 27, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now