Jump to content

niutech

Members
  • Content Count

    10
  • Joined

  • Last visited

Everything posted by niutech

  1. If you want to integrate Google+ Comments in your ProcessWire website, just follow the instructions from an article on Browsing the Net. In summary, insert the following HTML code into your template: <script src="https://apis.google.com/js/plusone.js"></script> <g:comments href="<?=$page->httpUrl?>" width="642" first_party_property="BLOGGER" view_type="FILTERED_POSTMOD"></g:comments> Change the width accordingly and in case you have a Google+ profile, link your page with Google+ profile to enable moderation features.
  2. @jploch: If you don't want to use PHP at all in your templates, why don't you try my Smarty Templating module? It's very easy to create a new template using Smarty tags and ProcessWire objects like {$page}.
  3. What's the purpose of adding Flourish to ProcessWire when you usually don't use most of its classes like ORM, Database, Filesystem or Session directly in templates?
  4. This is how you could do a portfolio site using Smarty Templating: First, build a structure like this: Projects (template: projects) - Project 1 (template: project) - Project 2 - Project 3 Tags (hidden, no template) - Tag 1 - Tag 2 - Tag 3 Second, for each project page add fields: - title - description - tags (type: page) - date - images Third, create the Smarty template file projects.php in your /site/templates, similar to this: {include './head.inc'} <h1>{$page->title}</h1> {* title of the Projects site *} {foreach $page->children as $child} {* we are looping through projects *} <div class="project"> <ul class="slider"> {foreach $child->images as $image} {* now we are looping through project images *} <li><img src="{$image->url}" alt="{$image->description}" /></li> {/foreach} </ul> <div class="rightside"> <h2><a href="{$child->url}">{$child->title}</a></h2> {* project title *} <p>{$child->description}</p> {* project description *} <p>Filled under: {foreach $child->tags as $tag} {* now we are looping through project tags *} <a href="{$tag->url}">{$tag->title}</a> {/foreach} </p> <p>Project added on: {$child->date|date_format:"%D"}</p> {* project date *} </div> {/foreach} {include './foot.inc'} Fourth, create the Smarty template file project.php with this content: {include './head.inc'} <h1>{$page->title}</h1> {* project title *} <ul class="slider"> {foreach $page->images as $image} {* now we are looping through project images *} <li><img src="{$image->url}" alt="{$image->description}" /></li> {/foreach} </ul> <p>{$page->description}</p> {* project description *} <p>Filled under: {foreach $page->tags as $tag} {* now we are looping through project tags *} <a href="{$tag->url}">{$tag->title}</a> {/foreach} </p> <p>Project added on: {$page->date|date_format:"%D"}</p> {* project date *} {include './foot.inc'} The rest is some JavaScript for sliders (e.g. Nivo slider) and a bit of CSS. (Disclaimer: I have not tested this code on a live server, writing from my mind)
  5. @Wanze, I thought by saving page you meant saving the template page, not the page contents. But now I have just added hooks to clear the cache on page & field save, using Ryan's snippet. Please give it a try and tell me if it works for you.
  6. @Ryan, Thanks for your tip, I have refactored the repo accordingly. @MatthewSchenker, As to evaluating PHP in Smarty templates, it is highly discouraged by Smarty itself, but it's still technically possible. Just replace: Smarty.class.php to: SmartyBC.class.php and: new Smarty(); to: new SmartyBC(); on lines 32-33 and insert a new line 43: $this->smarty->php_handling = Smarty::PHP_ALLOW; in SmartyTemplating.module file. @Wanze: I don't think it's necessary, since Smarty does it automatically: If $compile_check is enabled (default), every template file and config file that is involved with the cache file is checked for modification. If any of the files have been modified since the cache was generated, the cache is immediately regenerated.
  7. @Soma, I have fixed the Readme, now it's /site/modules. @Wanze, You can easily handle PHP logic inside Smarty templates, using {assign} and {function}.
  8. Couldn't the same level of caching as Pro Cache be accomplished by using plain old static HTML files? Bootstrap file index.php would include a small PHP file, which would make a static HTML cache of entire output from ProcessWire. Whenever the cache exists, it would be used instead of firing PHP. The included cache.php would look similar to this (based on cacheme.php): $cache_file = $_SERVER['DOCUMENT_ROOT'] . '/site/assets/cache' . $_SERVER['SCRIPT_NAME'] . '-static.html'; ob_start(); register_shutdown_function('cache_complete'); function cache_complete() { global $cache_file; file_put_contents($cache_file, ob_get_contents()); } and the sample rules at the beginning of .htaccess: #If these aren't POST requests... RewriteCond %{REQUEST_METHOD} !POST #...and admin panel pages... RewriteCond %{REQUEST_URI} !/processwire/ #...and requests with ?param=value... RewriteCond %{QUERY_STRING} ^$ #...and requests with cookie named nocache... RewriteCond %{HTTP:Cookie} !^.*nocache.*$ #...and if the static cached file exists... RewriteCond /site/assets/cache/$1-static.html -f #...then load the cached HTML file instead of PHP RewriteRule ^(.*) /site/assets/cache/$1-static.html [L] #Otherwise load the PHP script
  9. I've just integrated Smarty in ProcessWire, which seems to be faster than Twig. Details in another thread.
  10. Hi folks! First of all, I would like to thank @Ryan for such a flexible and nifty CMS as ProcessWire! However, I am used to Smarty template engine, which PW is lacking, so I have made a module to enable Smarty 3 templating, as well as I have converted the default PHP template to Smarty template. The source code is on GitHub: Smarty Templating for ProcessWire This is the initial version, so please send me your feedback. For syntax info, go to the documentation. Enjoy!
×
×
  • Create New...