Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/2018 in all areas

  1. I got tired of having to open the link dialog in CKEditor in order to check where a link is pointing to, so made this simple plugin. Link Hover A plugin for CKEditor. Shows the href attribute of a link in a tooltip when the link is hovered. This saves you from having to open the link dialog in order to check where a link points to. Installation This readme assumes installation in ProcessWire CMS. The plugin folder must be named "linkhover" – if necessary, rename the folder to remove the "-master" suffix added by GitHub. Copy the "linkhover" folder to /site/modules/InputfieldCKEditor/plugins/ In the field settings for each CKEditor field that you want to activate the plugin for, check the "linkhover" checkbox at Input > Plugins > Extra Plugins https://github.com/Toutouwai/linkhover
    9 points
  2. UPDATE 2022 Simple and powerful - put this at the end of your config.php file: $localConfig = __DIR__ . "/config-local.php"; if (is_file($localConfig)) include $localConfig; Then put all local settings into config-local.php (same concept for DEV/STAGING/PRODUCTION): <?php namespace ProcessWire; /** @var Config $config */ $config->debug = true; $config->advanced = true; $config->dbName = 'db'; $config->dbUser = 'db'; $config->dbPass = 'db'; $config->dbHost = 'db'; $config->userAuthSalt = '1234'; $config->tableSalt = '1234'; $config->httpHosts = ['xyz.ddev.site']; // this prevents logout when switching between // desktop and mobile in chrome devtools $config->sessionFingerprint = false; // RockFrontend $config->livereload = 1; // RockMigrations // $config->filesOnDemand = 'https://your-live.site/'; $config->rockmigrations = [ 'syncSnippets' => true, ]; // tracy config for ddev development $config->tracy = [ 'outputMode' => 'development', 'guestForceDevelopmentLocal' => true, 'forceIsLocal' => true, 'localRootPath' => '/Users/xyz/code/yourproject/', 'numLogEntries' => 100, // for RockMigrations ]; $config->rockpagebuilder = [ "createView" => "latte", ]; -------------------- OLD POST from 2018: Have you ever come across the situation where you needed to change your config.php file for local development? Have you ever come across this warning? Say goodbye to this little annoying tasks Some of you might know that you can have a separate config-dev.php file for local development. This is nice, but also needs some setup (for example excluding this file for git upload) and there is still some danger of uploading this file to a place where it should not be... The other option was to keep the database settings for your live and dev server in sync - also not easy and maybe not the best... My solution is as simple, fast and I think it should be even safer than the other options. Just put these lines at the end of your config.php file: if(strpos($config->paths->root, 'C:/www/') === 0) { $config->dbUser = 'root'; $config->dbPass = ''; $config->httpHosts = [$_SERVER[HTTP_HOST]]; $config->debug = true; } elseif(strpos($config->paths->root, '/var/www/vhosts/') === 0) { $config->httpHosts = []; $config->dbUser = 'XXX'; $config->dbPass = 'XXX'; $config->debug = false; /** * Redirect to HTTPS * ATTENTION: This will NOT work with ProCache enabled! Use .htaccess instead */ if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){ $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirect); exit(); } } else die('wrong config.php'); Having a separate config-dev.php file also makes it necessary to keep both files in sync. That was my first idea: To include the original config and then overwrite settings. But it's just simpler the other way round: Using the default config.php file and overwriting settings there.
    5 points
  3. i have a request in also to add hook to UI Kit theme, especially for being able to manipulate css files; i was able to sort out my issue (FontAwesomePro module) using another way, but i do think it is important to add api hooks in key/strategic areas on the admin themes, for customization. https://github.com/processwire/processwire-requests/issues/120
    4 points
  4. Sounds great! May I include this in... you know where? ?
    4 points
  5. Besides Adrian's excellent suggestions... Many of the common inputfield properties are outlined here: https://processwire.com/api/ref/inputfield/ For properties specific to a particular inputfield type you can read the code comments in the core files, or if you have the very handy API Explorer pro module you can browse the properties in a nice interactive interface within the PW backend:
    4 points
  6. I've played around a bit with setting up a blog in PW using @kongondo's blog module and, since I'm anything but not a designer, incorporated the free "Striped" template from HTML5UP. The result is Striped Travel Blog Template (Responsive). Update: link now points to the official module repository. The layout is classical (some might say "very nineties" ) but I do like sidebars on the left and content starting close to the top. Features are: You can the sort order for lists that are sorted by date to ascending or descending. This is the "killer feature" I'm missing everywhere else, and as an avid reader of hiking blogs (mostly long distance, so long series of blog entries) I always hate when "next" buttons take me backwards (in time) and lists have to be read top down. Post lists are paginated Since it uses the blog module, comments and email notifications for them are a given Contact form using @justb3a's Simple Contact Form module Auto-generated sitemap.xml using @Pete's XML Sitemap module The usual stuff like recent comments, recent posts, recent tweets Calendar for the current month with links to dates with pages 3-column home layout with posts, configurable number of posts shown there "Sticky" option for posts to glue them to home RSS feed Already added all templates with translatable strings to site translation files Todos: Add post overview by year and month Allow paging through the calendar widget by month I'm a bit of two minds whether to show the full posts in lists or just summaries and still have to decide on that As written in the title, it is still in development, and I'm not completely happy with the lack of integration of my additional site-wide settings with the blog module's settings widget. I just thought I'd share it. Of course, I'd be happy about any feedback. Screenshots:
    3 points
  7. URL segments that you enable on the template settings are just strings, not selectors, so ProcessWire won't be able to do this kind of check. But you can accomplish it by doing the following: On Template Settings, add a regex on the URL Segments field like: regex:^(map|carte)$ On your template code, add a check: // we are only using 1 URL segment, so send a 404 if there's more than 1 if($input->urlSegment2) throw new Wire404Exception(); if($input->urlSegment1) { //if there's any segment that matches the ones you specified on the Template Settings, PW will proceed. //do your code } Going to example.com/map or /carte will pass the conditional.
    3 points
  8. If you go to a field's settings in the admin and then open the Request Info panel in TracyDebugger you'll see this. It's most of the settings available, but some like "required" doesn't show unless you have it checked for the field in question. Alternatively, also while visiting a field's settings, you can do this in the Console Panel:
    3 points
  9. Hello, I recently posted in this topic, but I decided to start my own thread because while I believe my issue is related to the one in that thread, they are not exactly the same: I have created a custom User Template in the method outlined in the docs. I am creating a directory, so it made sense that every page in the directory was a Directory Member, so they could log in and edit their own information while also keeping the entire directory protected behind a login wall. So the new user type is created: "directory-member". I then created two new roles: "member" and "directory-admin": The "member" only has the ability to View directory-member pages, and "profile-edit", which allows them to manage their own information. The "directory-admin" has the ability to edit any directory-member pages, and administer users. Some Directory Members are both, but all have at least the "member" role. The first hint that something was wrong was when I was testing a "member" user and I could not add a new item to a repeater on that profile. The url for the profile edit (this will be important shortly) is site.dev/admin/profile. The repeater is set up to load new items through AJAX. If this option is turned off, the rest of this issue is no longer completely valid. But as I have found what I believe to be a pretty large issue in the Processwire codebase, I thought it worth bringing up. See, every page (even a user) has a $page->editUrl() method, and it returns a URL like this: site.dev/admin/access/users/edit/?id=2096. That's all good and fine for users that have page-edit permissions, but if they don't, that link will resolve to the admin's equivalent of a 404. So the way that Processwire currently gets around this is by creating a specific editing area for a user to interact with only their profile: /admin/profile. And that works pretty nicely, except for the fact that nowhere is editUrl() ever made aware of the difference. editUrl() is not hookable, and whether or not a page is editable is based on the PagePermissions module. On top of that, there are several core modules that hardcode a search-and-replace (see InputfieldRepeater.module:627) where the editing screen is for Users. This doesn't allow for a huge degree of flexibility that is offered in other places throughout Processwire. If line 627 of InputfieldRepeater is changed from this: $editorUrl = str_replace('/access/users/edit/', '/page/edit/', $editorUrl); to this: $editorUrl = str_replace('/access/users/edit/', '/profile/', $editorUrl); ...the AJAX repeaters work. It's maddening! As is brought up in the thread I attached above, a lot of the features of page editing are missing within /admin/profile/, and it just makes for an altogether strange editing experience. A user who has "page-edit" permissions for templates other than directory-member, but does have "profile-edit" permissions, will see their user in the Page List, but cannot edit their Page unless they hover over the wrench and click the "Profile" link. It just seems - off. I think what this hinges on for me is that the editUrl() of the user should be "/admin/profile/" if that user is logged in (and their page should be editable from the Page List), or the "/admin/access/users/edit/" url; regardless of the URL, both links should resolve to the Page Edit screen, as the Profile Edit screen seems to be a unnecessarily neutered version of Page Edit.
    2 points
  10. 2 points
  11. Thanks @neosin - it should be fixed in the latest version. Let me know if you find any issues.
    2 points
  12. Everything is working again. Nothing to do with PW version. It was all down to the children with no images after all. After doing better job with checking if the images exist it started working. if (count($child->images)) { // Original code here } Interesting that the width() crashed PHP but without it everything worked fine. Anyway, I'm little bit wiser now. Thank you for your help everyone, and sorry if you had a spend a lot of time mulling over this.
    2 points
  13. made huge progress on this Example query with all the features: $pages->findObjects('template=item, limit=100', [ 'title', // page title field 'field1', // regular textfield '(SELECT #data# FROM field_field1 WHERE pages_id = pages.id) AS `sql`', // custom sql query (multilanguage) 'images:description', // imagefield + description 'pagetest:status:created:templates_id', // pagefield + page status + created time + template id 'pagetitle' => function($page) { return $page->title; // example of a closure }, ]); Explanation: regular textfields can easily be queried just by defining their name as string any custom sql query is possible, even multilanguage when using #data# keyword images:description syntax works for all file fields page:status:created works for all pagefields and last but not least a very nice helper for fast and easy queries and small amounts of data: closures Output (default language): And the same query as datasource for a datatables field: This will be really, really awesome @theo I plan to add a lot of other stuff to my datatables module and that will take some time. I put the new pageFinder in a separate module. You can have a look here: https://gitlab.com/baumrock/RockSqlFinder Maybe you want to test it? Also @adrian might be interested? Currently it supports FieldtypeText, FieldtypePage and FieldtypeFile - but it should be easy to add others... Like Repeaters for example. Any other fields could be queried via custom SQL queries... And for really complex joins there will be another module
    2 points
  14. Edit: Because of the great response to this topic I wrote a guest blogpost: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/ One of the hidden treasures of processwire seems to be the creation of custom admin pages. Technically speaking those pages are ProcessModules - but i guess that's the reason why so many people out there seem to be afraid of building them... it sounds so hard! You've never created a module for ProcessWire? You have never created a plugin for any other CMS? You have no clue about OOP with all its classes, methods and properties? No problem! I'll show you how simple you can start: <?php class CustomAdminPage extends Process { public static function getModuleinfo() { return [ 'title' => 'Custom Admin Page Example', 'summary' => 'Minimalistic ProcessModule to show that nobody has to be afraid of building custom admin pages.', 'href' => 'https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/', 'author' => 'Bernhard Baumrock, baumrock.com', 'version' => 1, // page that you want created to execute this module 'page' => [ 'name' => 'customadmin', // your page will be online at /youradmin/setup/customadmin/ 'parent' => 'setup', 'title' => 'Custom Admin Page Example' ], ]; } public function ___execute() { return 'This is the most simple Admin-Page you have ever seen :)'; } } Now save this file as CustomAdminPage.module and place it in your /site/modules folder. After a refresh it will show your module in the modules manager of your site where you can install it: After installation you already have your first very own admin page! Congratulations! Was not too hard, was it? It's as simple as that! Now lets add some more custom HTML. And to show you another nice feature we will add this code to a separate method called executeDemo(). And because everything is so simple we will also add some javascript to this page public function ___executeDemo() { $out = ''; $out .= '<h1>H1 has some special css styling in the admin, thats why it seems to have no effect</h1>'; $out .= '<h2>H2 looks different ;)</h2>'; $out .= '<h3>...and so does H3</h3>'; $out .= '<button onclick="myFunction()">Click me</button>'; $out .= '<script>function myFunction() { alert("this is a demo javascript"); }</script>'; return $out; return ''; } Now thanks to ProcessWire-magic your page will already have its own URL: Just append /demo to your url and see what you get: And of course don't forget to click the button Ok, now that code looks a bit hacky, right? Inputfields and especially InputfieldMarkup for the win! We add another method with some advanced code. To use inputfields we need a form that holds all those inputfields and that makes it possible to handle user input lateron. See somas great tutorial about forms here for a quickstart and more details: public function ___executeAdvanced() { $out = '<h2>A more complex Example</h2>'; $form = wire()->modules->get('InputfieldForm'); $field = wire()->modules->get('InputfieldMarkup'); $field->label = 'Markup Test 1'; $field->value = '<h1>h1</h1><h2>h2</h2><h3>h3</h3><h4>h4</h4>'; $form->add($field); $out .= $form->render(); return $out; } Ok, it get's boring Let's do something more fun and add a chart in a second field and change the fields to 50% screen width (I'm sure you know that already from the GUI template editor)! public function ___executeAdvanced() { $out = '<h2>A more complex Example</h2>'; $form = wire()->modules->get('InputfieldForm'); $field = wire()->modules->get('InputfieldMarkup'); $field->label = 'Markup Test 1'; $field->value = '<h1>h1</h1><h2>h2</h2><h3>h3</h3><h4>h4</h4>'; $field->columnWidth = 50; $form->add($field); $field = wire()->modules->get('InputfieldMarkup'); $field->label = 'Chart Sample'; $field->value = '$chart'; //$field->notes = 'Example code taken from here: http://www.chartjs.org/docs/latest/getting-started/usage.html'; $field->columnWidth = 50; $form->add($field); $out .= $form->render(); return $out; } OK, we are almost there... we only need to add the chart library! To keep everything clean we will put the code for the chart in another method. We will make that method PRIVATE to add some security. Our new Method: private function renderChart() { // prepare chart code wire()->config->scripts->add('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js'); ob_start(); ?> <canvas id="myChart"></canvas> <script> var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); </script> <?php return ob_get_clean(); } Now we just need to call $this->renderChart() in the right place! Here is the complete Module: <?php class CustomAdminPage extends Process { public static function getModuleinfo() { return [ 'title' => 'Custom Admin Page Example', 'summary' => 'Minimalistic ProcessModule to show that nobody has to be afraid of building custom admin pages.', 'href' => 'https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/', 'author' => 'Bernhard Baumrock, baumrock.com', 'version' => 1, // page that you want created to execute this module 'page' => [ 'name' => 'customadmin', // your page will be online at /youradmin/setup/customadmin/ 'parent' => 'setup', 'title' => 'Custom Admin Page Example' ], ]; } public function ___execute() { return 'This is the most simple Admin-Page you have ever seen :)'; } public function ___executeDemo() { $out = ''; $out .= '<h1>H1 has some special css styling in the admin, thats why it seems to have no effect</h1>'; $out .= '<h2>H2 looks different ;)</h2>'; $out .= '<h3>...and so does H3</h3>'; $out .= '<button onclick="myFunction()">Click me</button>'; $out .= '<script>function myFunction() { alert("this is a demo javascript"); }</script>'; return $out; return ''; } public function ___executeAdvanced() { $out = '<h2>A more complex Example</h2>'; $form = wire()->modules->get('InputfieldForm'); $field = wire()->modules->get('InputfieldMarkup'); $field->label = 'Markup Test 1'; $field->value = '<h1>h1</h1><h2>h2</h2><h3>h3</h3><h4>h4</h4>'; $field->columnWidth = 50; $form->add($field); $field = wire()->modules->get('InputfieldMarkup'); $field->label = 'Chart Sample'; $field->value = $this->renderChart(); $field->notes = 'Example code taken from here: http://www.chartjs.org/docs/latest/getting-started/usage.html'; $field->columnWidth = 50; $form->add($field); $out .= $form->render(); return $out; } private function renderChart() { // prepare chart code wire()->config->scripts->add('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js'); ob_start(); ?> <canvas id="myChart"></canvas> <script> var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); </script> <?php return ob_get_clean(); } } I hope you enjoyed reading this and it will open up many new possibilities for you! Updates: permissions: https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/?do=findComment&comment=174746 tutorial on file uploads: https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/?do=findComment&comment=185261 snippet how to use NavJSON: https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/?do=findComment&comment=216412
    1 point
  15. In terms of adding markup to admin themes, the following hookable methods are common to all admin themes: AdminThemeFramework::getUserNavArray Allows you to add items to or remove items from the "user" dropdown menu (Edit Profile, etc). AdminTheme::getExtraMarkup Allows you to add markup to the following regions of the admin template: head notices body masthead content footer sidebar For example... $wire->addHookAfter('AdminTheme::getExtraMarkup', function(HookEvent $event) { $regions = $event->return; $regions['masthead'] .= '<p>hello</p>'; $event->return = $regions; }); So not every place in the admin theme markup is covered (I don't see how it could be), but it allows for simple additions to the admin theme. No doubt you would need some custom admin CSS to position and style whatever markup you add. Other approaches... Manipulate the rendered markup string For some cases this might do the job. For example... $wire->addHookAfter('Page::render', function(HookEvent $event) { $page = $event->object; if($page->template == 'admin') { $out = $event->return; $out = str_replace('<div class="uk-navbar-right">', '<div class="uk-navbar-right"><p>hello</p>', $out); $event->return = $out; } }); Copy your preferred admin theme module from /wire/modules/AdminTheme/ to /site/modules/ Make whatever changes you need to the copied files, perhaps by including a separate PHP file at the right place in the template markup. That will make it easier to update the admin theme module from the core version when you choose to.
    1 point
  16. To check if a given file exists, I think you would be better off using PHP's file_exists(). It's very fast and it caches so I doubt it would have any significant impact on performance.
    1 point
  17. Unless you will be storing the result of an initial check (e.g. in a session or cache), you will have to check for the existence of the file. That aside, do you really need a hook for this? If I got you correctly, couldn't you do the check in the template file itself or that would mean repetitive code? If you did the check in init.php, you wouldn't need to have the same code check in different template files. I don't know if I am making sense, so on to an example. If you had this in init.php (assuming you are using delayed output). $templateName = $page->template->name; $customTemplateFile = $config->paths->templates . 'fields/content/' . $templateName . '.custom.php'; // if user is superuser (or user of your choice) AND we have a readable template file (e.g. home.custom.php) // ... we include it if($user->isSuperuser() && is_readable($customTemplateFile)) { include($customTemplateFile); } // else, include normal template file for this page else { include("./basic-page.php"); }
    1 point
  18. No problem! Regex to the rescue! Take a look at other examples here: https://processwire.com/docs/admin/setup/templates/#which-url-segments-do-you-want-to-allow
    1 point
  19. thank you for the quick fix! +1
    1 point
  20. Hi @bernhard, my use case is to find this type of hook for the main navigation and prepend or append something to it. In Reno Admin theme (but also in the default admin theme too) we could achieve this with the following code $wire->addHookAfter('AdminThemeRenoHelpers::topNavItems', function($event) { $out = $event->return; $out .= '<li><img src="path/image.png"></li>'; $event->return = $out; }); Whereas you cannot leverage a similar hook to the Uikit theme (the latter soon to be the default theme). Am I correct?
    1 point
  21. Yeah it really is an incredible improvement when you don't need all the stuff associated with a full PW page object.
    1 point
  22. Not to forget the memory drop from 20.63MB to 0.15MB
    1 point
  23. Hey @bernhard - new version is much better - thanks. I tested with 5000 pages and it is an order of magnitude faster than a regular find()
    1 point
  24. Thanks @3fingers, I completely had a brain fart in regards to using strtolower() on a $var.
    1 point
  25. Something like this? <?php $dash = $pages->get("/dashboard/"); $dashchildren = $dash->children(); $out = ""; foreach($dashchildren as $dashchild){ $out .= "<p>" . "<a href=\"{$dashchild->url}\">" . "{$dashchild->title}" . "</a>"; foreach ($dashchild->children as $dashgrandchild) { $dashgrandchild_title = strtolower($dashgrandchild->posistion->title); $out .= "<span class=\"{$dashgrandchild_title}\">" . "{$dashgrandchild->title}" . "</span>"; } $out .= "</p>"; } echo $out; ?>
    1 point
  26. This works?? strtolower($page->options_field->title);
    1 point
  27. Glad you sorted this out. Even though I would change the main selector as @rafaoski suggested, to retrieve only those pages that have images, imo it's a bit more performant.
    1 point
  28. Issue report: https://github.com/processwire/processwire-issues/issues/539 Thank you.
    1 point
  29. Oh, it's a theme issue? Sorry, never used other AdminTheme.
    1 point
  30. I just installed this module and with PW 3.0.95, Tracy shows me the following notices PHP Notice: Trying to get property of non-object in ...\RestrictMultiLanguageBranch.module:140 line 140 code: if($p->id === 1 || !isset($this->data['multilanguageStatus'][$this->closestSpecifiedParent->id])) {
    1 point
  31. Thanks adrian, I also noticed that but it seems it was too late yesterday... forgot to check if there are any closures to execute so it loaded all the page objects even if there were no closures please check the update: https://gitlab.com/baumrock/RockSqlFinder/blob/master/RockSqlFinder.module.php#L59 Very interesting (and great imho) is also this test using closures: So, of course with closures it is a LOT slower (because we load the page objects in memory), but the additional costs for each closure are less than for the first one. Thats because the page is already available in memory after the first closure: https://gitlab.com/baumrock/RockSqlFinder/blob/master/RockSqlFinder.module.php#L62-63 And finally one with "images:description" syntax: And insanely fast without the closure @all Any ideas wich character to use for image field descriptions (and maybe other fields)? At the moment I'm using the pipe, but that would lead to problems when a user uses the pipe for descriptions (see the above screenshot) For file- and page fields the pipe should be fine because we could use it directly for further selectors and files should not contain any pipes.
    1 point
  32. Best way to search the modules directory is via the PW Info panel in TracyDebugger:
    1 point
  33. duh.. i had another fieldtype installed.. somehow i cant find it now in the moduels.... that one is much better.. just pasted the wrong link here.. i had install Thanks for the Help
    1 point
  34. Just playing around with it now - so far looks fantastic in implementation. The only catch is that I am actually seeing slower response times. Take these two examples: VS Note that I am using the Console panels ability to only run the selected code. The ms values don't look good though for some reason - any ideas why?
    1 point
  35. De-installed is not quite the same as physically removed. If you de-activate a PW module, it will still be on your server. But all DB-related stuff will be removed (not every module uses the DB). Hint: Most old modules not tagged with "PW3-compatible" can be easily enabled with adding PW3 namespaces at the very top of the php (.module) file: <?php namespace ProcessWire;
    1 point
  36. OK it is working now. For the overview page i used: <p class="text-center">veröffentlicht am <?= $blog_post->page_published ?></p> And for my single blog page i used: <p class="text-center">veröffentlicht am <?= $page->page_published ?></p> So creating an extra field and put this in the single blog file is like a workaround.
    1 point
  37. What's your environment like? If you're on xampp, check the logs for clues or maybe try laragon. I find it easier to work with and haven't had problems with the last few (10+) machines that I had to install/setup ProcessWire on.
    1 point
  38. This week we take a look at something really cool we added a few months ago but haven’t told you about yet: owner selectors. We also take a brief look at what’s new in ProcessWire 3.0.95 and and the status of our next master version, which is just about ready! https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
    1 point
  39. Welcome to the forums and ProcessWire @h365. Some have found this topic useful when it comes to content/data relations
    1 point
  40. Here is a new created version to track changes which works without any problems and you dont have to take care about the deletion of input values if the page was not saved successfully (like in the version before) Put this little piece of code inside your ready.php. //Compare before and after values and output a warning message $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); $page->of(false); //configuration: change it to your needs $templates = ['event_businessvacations', 'event_dates', 'event_events', 'event_specialbusinesshours']; //array of templates where this hook should run $fields = ['summary', 'body']; //array of fields which should be checked //configuration end if(in_array($page->template->name, $templates)){ $changedfields = []; foreach($fields as $fieldname){ if ($page->isChanged($fieldname)) { // Page as it is in the DB $oldPage = wire('pages')->getById($page->id, array( 'cache' => false, // don't let it write to cache 'getFromCache' => false, // don't let it read from cache 'getOne' => true, // return a Page instead of a PageArray )); $changedfields[] = $oldPage->fields->$fieldname->label; } } $changedfields = implode(", ", $changedfields); if(!empty($changedfields)){ $this->warning(__("The following fields have been changed: {$changedfields}")); } } }); Change the configuration block to your needs (template names, field names). This little code snippet outputs only a warning message which fields have been changed - not more or less, but you can also run some other logics - its up to you. Note: Works also with repeaterfields, but you can only check the repeaterfields for changes in general. It is not possible to check for specific fields inside the repeater.
    1 point
  41. Little admin helper module: Using this module you can view all template cache settings at once. E.g. cache status, cache time (configurable). Furthermore it adds the functionality to clear the entire template cache or just the template cache for a given template. Note that this may cause a temporary delay for one or more requests while pages are re-cached. GitHub: https://github.com/justb3a/processwire-templatecacheoverview
    1 point
  42. You can set a default template by supplying the GET parameter “template_id”, or the POST parameter “template”: http://example.com/processwire/page/add/?parent_id=1024&template_id=46 I’m not sure about forcing the template. You could probably specify a default name format in order to bypass the page-add screen directly, or hook into ProcessPageAdd to manipulate the form.
    1 point
  43. For relative URL, you can use: <a href="<?php echo $pages->get(23)->url;?>">Page with ID 23</a>If you want the full http URL, use ->httpUrl instead of ->url. Edited to add: Sorry, forgot to add the 's' to $pages - totally different variable
    1 point
  44. With Processwire there are no directories in the admin. It is all pages. Pages can be used for anything (not just a page full of information). They can be used as a placeholder, or an option for a select (using the page field), or as an actual container for data. Your articles are pages, your categories are pages, your tabs are pages. What makes them different is that you would use a particular template to reflect what that page needs to achieve. Those templates may not have a template file associated with them - you only need to do that if you are formatting the data held in that page AND calling the page directly. (You can get information from another page by using $pages rather than $page) All pages do have relationships to parents and children, and using their template, you can dictate how that relationship works. For instance if you had a hidden page called "Posts" under home, and it had a template called "Post-Placeholder" which had no fields other than the title field, then you can set the template so that any children of "Posts" had to have a particular template - your "news" template, for instance. So you can limit the choices to make the system more manageable. It is up to you what a page is pretending to be, if you like! Just play with multiple pages and templates and you will soon see how you can relate them together and therefore how you can design just about any structure you need.
    1 point
  45. I am putting together a blog solution at the moment and the way I am doing it is this: (remembering that this is just one way) Main Menu: Home (er, obviously) Category 1 -- subcat ---- subcat Category 2 -- subcat ---- subcat Category 3 -- subcat ---- subcat ---- subcat ---- subcat ------ subcat Category 4 -- subcat ---- subcat So, those could for instance be Sport, Politics, Media and so on with a category tree underneath of any complexity. Articles are actually just being added as children to a hidden page called Articles and have a page field to select one category. They are all in one list (as with things like WordPress) though you could break them up if you wanted for management purposes. It does help for development purposes, if all your articles have either the same parent OR the same template (one or the other). It makes dealing with them easier. In my case, because I have very different post types (and therefore associated templates) I have gone for a common parent approach and will rely on the search or the front end to find things Then... I have a pile of tags under a hidden page called Tags. These are also selected by the article using a page field, but you can select multiple tags and add new ones. I also have Topics, again under a hidden page. You can make any article select several topics, but not add new ones. Topics are being used as cross references. So you may have a topic called "Politics in sport." This would be used for an article about sport that had a political bent that you want listed primarily in the Sport category. I also have authors, which can be yet another sort method. EDIT: Almost forgot, I have several article types - Video, Photoblog, Standard Blog, and so on. So articles can be filtered and listed using that criteria (basically which template is being used). Second Menu I have a top bar that has dropdowns for all topics and all categories as a quick link/cross link system. You can also search just as normal or filter the search by category and/or topic. The top bar also will have links to About and Contact so that the main menu is very much dedicated to just the articles. That is the basic skeleton. After that, it is down to useful tools. For instance I have created a widget that lists recent posts in the same category as the post you are viewing is in. I could also create one that worked on topics. You could use the categories as either single entities where each category only lists those articles that belong to it, or you could use them as filters. So, a top level category would list all articles belonging to it and any sub categories, a subcat likewise and so on down the tree. There are rather a lot of ways to skin the ProcessWire pet cat, to be honest. The main thing with news (which is nothing to do with ProcessWire as such) is that you have to allow quick and random browsing through main areas (like you would with a printed newspaper so your home page (and other pages) should lay out your wares nice and clearly, and you need to make sure you have some sort of editorial control with different groups allowed to do different things. In principle, my approach is similar to Ryan's. but with some variations that suit my brain!
    1 point
×
×
  • Create New...