pandaman Posted April 18, 2017 Share Posted April 18, 2017 Sorry for the long title, but it explains well my doubt: for a corporate site, with all the pages looking the same, like the Skyscrapers demo, i know how to work. But usually i did simple sites for little clients (with 1 or 2 languages), where creativity is most important of the content. I moved to Processwire, from Wordpress, because maintining is a time-consuming operation and i wanted something "easier", especially when clients ask for new functionalities to integrate. Something like this site http://kl-webmedia.com/demo/owkey/index.html I worked with WP for years, sometimes i used third-party templates, and i started to work writing the HTML code in the body of the posts/pages. That was the way, more or less, in Wordpress. Now i'm using Processwire, and i used the same method. I created some fields, based on a textarea (not the body one used in the demo, because i don't need the text editor), inside a main template. So, the main content is managed inside PW pages backend. if you have to do the same site i linked, do you use the same method, or do you put the html in a template php file, and create inside PW a template for each page? Because every page have a lot of different tags and divs, with parallax, containers, big photo, fancy graphics, and i don't undestand if is easier managing the code inside PW, or outside in the php files (making all the text a translatable string). It's a simple question, with a lot of different answers, all correct Link to comment Share on other sites More sharing options...
abdus Posted April 18, 2017 Share Posted April 18, 2017 For user generated content, I use textarea fields with Parsedown (a flavor of Markdown) module in tandem with this module for images. This provides a simple syntax for semantic HTML (accepts raw HTML as well). For the parts that that are not open to user modification, I simply write HTML inside PHP files, and sprinkle PHP echo (<?= $var ?>), foreach, if constructs etc here and there. While starting out, I put everything in one PHP file, and as I build the layout and styles, I gradually refactor some parts into their own partial templates. I heavily utilize partial templates with wireRenderFile() and region() functions (you'll need to enable Functions API inside config.php as $config->useFunctionsAPI = true). I renamed wireRenderFile as partial(), (you can go even shorter with p()) like this. <?php /** * Renders partial with given data and returns generated markup * * @param string $template template to use. must be located in templates/partial * @param array $data associative array to pass to template * @return bool|string generated markup */ function partial(string $template, $data = []) { return wireRenderFile($template, $data, [ 'defaultPath' => paths()->templates . 'partial' ]); } and employ it inside template files and other partial templates as <?php // /site/templates/blog.php $posts = pages("template=post, parent=$page, sort=-published"); region('header+', partial('page-header', ['class' => 'header--large wrap'])); region('content+', partial('post-list', ['posts' => $posts])); include_once('layouts/basic.php'); For navigation, I use a custom template called nav, which only has a YAML field like this, and switch to other navigations (specified using other pages with nav template) on different contexts. - title: Blog url: /blog/ - title: Somewhere url: https://google.com external: true 1 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