Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/08/2012 in all areas

  1. I found (after 2-3 Projects using PW) that it's a good technique to use templates in a way I think hasn't been thought of yet really by some. (Although the CMS we use at work for year, works this way.) I'm sure I'm maybe wrong and someone else is already doing something similar. But I wanted to share this for everybody, just to show alternative way of using the brillant system that PW is. Delegate Template approach I tend to do a setup like this: - I create a main.php with the main html markup, no includes. So the whole html structure is there. - I then create page templates in PW without a file associated. I just name them let's say: basic-page, blog-entry, news-entry... but there's no basic-page.php actually. - Then after creating the template I make it use the "main" as alternative under "Advanced" settings tab. So it's using the main.php as the template file. - This allows to use all templates having the same php master template "main.php" - Then I create a folder and call it something like "/site/templates/view/", in which I create the inc files for the different template types. So there would be a basic-page.inc, blog-entry.inc ... - Then in the main.php template file I use following code to delegate what .inc should be included depending on the name of the template the page requested has. Using the TemplateFile functions you can use the render method, and assign variables to give to the inc explicitly, or you could also use just regular php include() technic. <?php /* * template views depending on template name * using TemplateFile method of PW */ // delegate render view template file // all page templates use "main.php" as alternative template file if( $page->template ) { $t = new TemplateFile($config->paths->templates . "view/{$page->template}.inc"); //$t->set("arr1", $somevar); echo $t->render(); } <?php /* * template views depending on template name * using regular php include */ if( $page->template ) { include($config->paths->templates . "view/{$page->template}.inc"); } I chosen this approach mainly because I hate splitting up the "main" template with head.inc and foot.inc etc. although I was also using this quite a lot, I like the delegate approach better. Having only one main.php which contains the complete html structure makes it easier for me to see/control whats going on. Hope this will be useful to someone. Cheers
    1 point
  2. I heard of PW from a few posts (Txp CMS forum) and from tweets from folks like Alan. By the 4th (or so) mention, I visited the main site and watched Ryan's video and decided to try it out myself. A few weeks later I am still here, have migrated a site over to PW and am now writing my first module for it.
    1 point
  3. I found PW like this (and NO disrespect to Textpatten which I admire and have used to great effect): started a new project in TXP (Textpattern) went to do a couple of things that needed plugins and was tripped over by plugins not working made an executive decision that I had had enough of relying on plugins that generous people had shared but that inevitably they had sometimes stopped maintaining and decided, with reluctance, to train on EE bought $48 worth of video training and began to learn EE found EE was a little like a clunky version of TextPattern in some regards but inevitably due to it's commercial footing more complete and with an ecosystem of high-grade plugins — I was a little saddened to see I still needed to rely on plugins and even sadder* to see they often cost $30, $60, $+ (on top of the $300 for EE the client pays) but soldiered on and kept learning (*but I recognize that charging for good plugins is right in many cases) was Googling re EE and found Marty Walker's web site http://www.smd.net.au/ and as usual scrolled to the bottom to look at some meta and read "ProcessWire" and not EE, "Hmm" I thought clicked "ProcessWire" and never looked back Thank you Marty and thank you PW community for your help and most of all, thank you Ryan for creating, sharing and driving this superb project.
    1 point
  4. I tested the suggestion of Netcarver and it works. On your code, it would look like this: if( 0 == $testimonial->getItemKey($item) % 2) @Netcarver, getItemKey() is on the cheatsheet. Make sure you have the "advanced" checkbox checked
    1 point
  5. You will see that unless you reset the $class to '' each time around the loop. Try something like... ... foreach ($testimonial as $item) { $i++; if(0 == $i % 2) { $class = 'odd'; } else { $class = ''; } ?> ...
    1 point
  6. In native PHP you can do as Soma said before. But I agree that it would be nice to have this built in the API. Let's wait that Ryan comes back to see what he will say about this
    1 point
  7. Have been on a merry-go-round of open-source CMSs for a while now. I seem to spend a couple of days once a month, desperately looking for something that fits my workflow. I have to say that this workflow has been very heavily influenced by ExpressionEngine. Custom fields is the biggest must for me, I am constantly debating with my brother who is an avid Joomla man, the merits of custom fields per channel(ahem 'page') and I can never believe that it just isn't possible in most other CMSs. I have to say that I've come to PW primarily because I cannot always afford to go the EE route, I genuinely love that platform. I am more and more getting the feeling though that even though I was attracted to PW as a cheaper alternative to EE, it may actually be STRONGER in many ways, though I'm at a very early stage with it. One final point, Ryan (and others') kindness, openness and support shine through in not only these forums but also the docs and intro videos. If I stick at PW and make it work for me, this will have been a huge factor - I genuinely feel that you care and that is incredibly important. I got turned off PyroCMS (as one example) because it felt exactly the opposite.
    1 point
  8. About 5 month later, I have nearly the same problem and can not explain to myself what's going on. I want to use pagination on the homepage/ root page. I created a homepage template that displays articles from this structure: /homepage/articles/article. So I try to paginate all the single articles lying beneath "/homepage/articles/" (hope this is not confusing). It's HOME ARTICLES Article 1 Article 2 Article 3 ... I was trying this code: $results = $pages->find("template=article, limit=15, sort=title"); if(count($results)) { $pagination = $results->renderPager(array( 'nextItemLabel' => "next", 'previousItemLabel' => "prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>" )); echo $pagination; echo "<ul>"; foreach($results as $result) { echo "<li><p><a href='{$result->url}'>{$result->title}</a><br /><span class='summary'>{$result->articleDescription}</span></p></li>"; } echo "</ul>"; echo $pagination; } As result, I get the pagination navigation, but it's not working correctly. Clicking through the pages shows always the same results. This query didn't work eather: $results = $page->child("title=articles")->children("limit=5"); Any ideas? I was now trying for hours...
    1 point
×
×
  • Create New...