Jump to content

bernhard

Members
  • Posts

    6,671
  • Joined

  • Last visited

  • Days Won

    366

Everything posted by bernhard

  1. Hi everybody, having worked mostly in the backend for the last weeks and having an upcoming project where I need some frontend stuff soon, I played around with a new concept of creating frontend themes for ProcessWire. That idea is not new... Nico built WireThemes back in 2014 and @teppo has recently launched WireFrame. I've also built two websites using this module (screencast) but that turned out to be too complicated and it was also working only with the uikit frontend framework. But still, it feels like I'm doing a lot of unnecessary work with every frontend project: Getting the framework Setting up the design Setting up the menu Setting up the correct dependencies (scripts, fonts, icons, etc) Setting up the config (markup regions etc) Setting up site settings (logo upload etc) etc, etc A lot of this stuff is the same for every site, so I'd really like to have a solution that is plug&play where I just have to do the customizations and not reinvent the wheel over and over again with every project. Also, I'd like to have everything in place so that I can just git clone a theme and share one theme across multiple projects (just think about the site header with favicon, seo and social tags!). Meet RockThemes ? As you can see in the video, the process is quite straightforward. Just install RockThemes and copy your theme to the templates folder (and set $config->theme to point to that folder, which was already in place in the video). The current status is quite promising: Themes stay entirely in the templates folder One year ago I decided to create themes as PW modules. That makes things complicated because assets are blocked by .htaccess from direct public access! Now themes live in /site/templates and assets are easily accessible for the public. The module uses Markup Regions by default They are great and offer so much flexibility and power. They are perfect for such a module ? The template files stay clean and easy, eg the footer file of the theme: <region pw-replace="footer"> <p>Powered by <a href="http://processwire.com">ProcessWire CMS</a> &nbsp; / &nbsp; <a href="/admin/">Admin Login</a></p> </region> Or the basic-page template (that gets the date from the site profile's template file and just populates the regions): <?php namespace ProcessWire; $sidebar = null; include("../basic-page.php"); ?> <region pw-replace="mainleft"> <h1><?= $page->title ?></h1> <?= $content ?> </region> <region pw-replace="mainright"><?= $sidebar ?></region> Themes are extendable This means that you can build one default master theme that you share across your projects and then create one custom theme per project that only contains the files that you need to change. The module supports any CSS framework I've built a base module that can be extended for every framework. The base module will consist functions that every project needs (eg for rendering favicon markup or SEO tags). The framework version will then extend this module with framework specific functions like rendering a menu or rendering paginations. Switching layouts is as easy as changing one file default.php <div class="uk-container"> <section id="header"></section> <hr> <section id="main"> <div class="uk-grid-divider" uk-grid> <div class="uk-width-expand"> <div id="breadcrumbs"></div> <div id="mainleft"></div> </div> <div class="uk-width-1-3@m" id="mainright" pw-optional></div> </div> </section> <hr> <section id="footer"></section> </div> colorful.php <section class="uk-background-primary uk-light"> <div class="uk-container" id="header"></div> </section> <section class="uk-background-muted"> <div class="uk-container"> <div id="breadcrumbs" class="uk-margin-top"></div> </div> </section> <section class="uk-section-small" uk-height-viewport="expand: true"> <div class="uk-container" id="mainleft"></div> </section> <section class="uk-background-muted uk-section-small" pw-optional> <div class="uk-container" id="mainright" pw-optional></div> </section> <section class="uk-section uk-background-secondary"> <div class="uk-container" id="footer"></div> </section> All other files are unchanged! This of course only works if the regions are named exactly the same. That would lead to the challenge of having the same region names across our themes. I guess that's the case for all CMSs that have theming support? I can remember the times when I worked with joomla (content-top, top, header-a etc). Would it make sense to create a master layout that can be used for almost every project? What regions are you using in your projects? I think such a frontend framework could open up a lot of possibilities. It would for example be a lot easier to develop helper modules for the frontend (think of RockTabulator or something like FREDI) because we would finally have at least a very basic standard how things are done (eg how to add assets to the <head>). It could also be easier to work on projects in a team, because everybody would know how things work. Though, I'm still not sure if such a module would make sense for the public at all. I'd be especially curious what @teppo thinks about that and how you see that approach compared to WireFrame (I wanted to use it before I started this module, but it did not feel right for me). Maybe that's exactly the problem: When it comes to frontend framework / theming approaches things just don't feel right, because everybody is so used to his workflows. So what do you guys think? Would such a module make sense to you? Would you be using it? If yes, what would be necessary features? What would be no-go's?
  2. Hi @nabo See the example for changed order status here: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks You know about Tracy? ?
  3. Just played around with your example and did a little refactoring ? Thx for sharing your code! $this->addHookAfter('ProcessPageList::find', function(HookEvent $event) { $pages = $event->return; $excludePagesByTemplate = array('admin', 'basic-page'); $pages->each(function($p) use($pages, $excludePagesByTemplate) { if(!in_array($p->template, $excludePagesByTemplate)) return; if(!$p->editable() && !$p->addable()) $pages->remove($p); }); $event->return = $pages; });
  4. The page add step is skipped because of your settings that you linked to above. Not really: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks (2015 ? )
  5. You can set the title and name after the page was added: // site/ready.php $this->addHookAfter("Pages::added(template=yourtemplate)", function($event) { $page = $event->arguments(0); $page->setAndSave('title', 'foo'); $page->setAndSave('name', 'foo'); }); You might want to make sure that the name is uniqe (https://processwire.com/api/ref/pages-names/unique-page-name/)
  6. Hey @ryan I tried setting a different templates folder today but the result seems weird to me. Am I doing it wrong? I'd have expected that if I set the templates location to /site/templates/theme1 the homepage should show /site/templates/theme1/home.php but in fact it shows a 404 because /site/templates/home.php does not exist and the page is taken as not viewable... Is that expected?
  7. Starting fresh and importing the old data might also be an option. When I think of sites that I built 5 years ago I'd definitely build them completely new ? If you have to redo the design anyhow that should not be too much work and you can refactor things easily and improve quality and maintainability.
  8. The better the questions the better the answers. You cannot expect that forum members can remember the exact problem that you have posted several weeks ago. Describe your problem. Try to make it reproducable (eg by providing a site profile of a clean installation that shows the problem) and I'm sure there will be someone who can help you. Sometimes even describing the problem as good as you can brings you to the solution ?
  9. I'd create a PHP script where you bootstrap PW and execute it from the command line: You have the same PW version that your live system runs on and therefore you have the same sanitizer methods. You can do a dry run and only echo the file name conversions before you really copy files over. And you can watch everything in realtime. +1
  10. if($page->block_page) echo "{$page->block_page->title}";
  11. d($page->children()->count); // 7 $foo = $pages->get(1); $page->children()->add($foo); d($page->children()->count); // 8 d($page->children('id>2000')->count); // 3 $page->children('id>2000')->add($foo); d($page->children('id>2000')->count); // 4 $pages->uncacheAll(); d($page->children('id>2000')->count); // 3
  12. Now you can join any finder to any column of another finder. That's quite powerful but might also get complicated or slow... It's especially handy when you want to use RockFinder2 as datasource of a RockGrid, because RockGrid does not support the new concept of relations that where introduced to RockTabulator https://github.com/BernhardBaumrock/RockFinder2/commit/8c6b66ad3dda68de9c1008078420f13a034250bf
  13. What happens if you replace this with the hardcoded url in the tracy example? Just replace block after block with working snippets and you'll find the problem or can at least narrow down where it is and tell us more about it ?
  14. Could you please explain by example what you are trying to achieve? At the moment I understood you like this: Public users should be allowed to view all public pages, but not page XY User foo should be allowed to view ONLY page XY (template bar) but not all public pages Same here. Or I didn't understand you ?
  15. No, I'm asking because if you are logged in and it works it might be because caching is disabled when logged in. On DEV caching is likely also disabled so that could explain why it works there. Is the not-working form somewhere online to check?
  16. Do you have any kind of caching involved?
  17. $page->closest() might be the slightly better option (or might not): https://processwire.com/api/ref/page/closest/
  18. That sounds like a good solution. Are you not happy with it? RockFinder2 might be overkill here, but if you have it available it might be an option: "owner" is a regular single page field. Or if you need multi-page-values:
  19. Did you develop that site or someone else? Maybe there are some hooks in place. Did you try connecting in an incognito window (without any cookies set)?
  20. <div class="headshot center-block" style="background-image:url('<br /> <b>Notice</b>: Trying to get property of non-object in <b>/home/drumming/ams.staging.gooi.ltd/site/assets/cache/FileCompiler/site/templates/home.php</b> on line <b>214</b><br /> ');"></div> Not the reason but something I found twice in your code and you might want to fix ?
  21. Little tweak that you can add to your config.php on DEV to support bootstrapping of PW (in that case there is no SERVER_NAME set and you need to define it manually): <?php if(!defined("PROCESSWIRE")) die(); // make bootstrapping possible $const = get_defined_constants(true); $host = $const['user']['host'] ?: $_SERVER['SERVER_NAME']; $config->dbUser = 'root'; $config->dbPass = ''; $config->httpHosts = [$_SERVER[HTTP_HOST]]; $config->debug = true; switch($host) { case 'www.foo.bar': $config->dbName = 'foo'; $config->userAuthSalt = 'bar'; break; } Then you can execute any script like this: <?php namespace ProcessWire; define('host', 'www.foo.bar'); include('index.php'); foreach($pages->find('limit=100') as $p) { echo $p->path . "\n"; }
  22. Just added support for sending variables to getByName() // RockTabulator grid setup, eg dogs.php $dogs = new RockFinder2(); $dogs->getByName('animals', ['type' => 'dog']); $grid->setData($dogs); // finder setup, eg animals.php if(!$type) $type = "cat|dog"; $rf = new RockFinder2(); $rf->find("template=$type"); return $rf; Also added a simple orGroups() method (see https://github.com/processwire/processwire-requests/issues/331? $rf = new RockFinder2(); // setup selector $selector = ['parent' => '/foo/bar']; if($from AND $to) { // show items that are not in the future $selector[] = ['date_start', '<', $to]; // show items that ended this year or not yet $rf->orGroup($selector, [ ['date_end', '>=', $from], ['date_end', '=', ''], ]); } ...
  23. I had some weird symbols in that file where the base64 encoded string was. No idea where they came from, but I will only investigate if the problem occurs again. Thx for your help!
×
×
  • Create New...