Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/07/2015 in all areas

  1. Try something like this in your ready.php: $this->pages->addHookAfter('saveReady', null, 'buildName'); function buildName($event) { $page = $event->arguments[0]; if($page->template != 'cruise') return; $page->title = '$page->parent->title . '-' . $page->date . '-' . $page->boat_name'; $page->name = wire('sanitizer')->pageName($page->title,true); } EDIT: You may also want to make use of the Name Format for Children option so that the page title/name initial dialog is not needed. You could have this set to create a dummy name since the code above will rename after anyway.
    5 points
  2. Well you might wanna check into the docs a bit for how to create a simple module that hooks before save. The logic is that you will change the data on the page and then when it is finished saving (as you will be modifying the data on the page before it is comitted) your data will be present. Good place to start: http://processwire.com/api/modules/ or http://modules.processwire.com/modules/helloworld/ Also are you trying to create this page title so that you can display it as the pages title in your head? If so you can also just echo out those fields. <head> <?php $pageTitle = $page->title; $pageTitle .= ' | '.$page->fieldName; $pageTitle .= ' | '.$page->fieldName2; ?> <title><?=$pageTitle;?></title> </head> Or are you trying to create this so that you can view the pages a certain way in your admin, if so then they have you covered here. Go to the template that you are wanting to see the title in a certain format and go to the advanced tab.
    3 points
  3. You can click the Download Zip button on this page: https://github.com/ryancramerdesign/ProcessWire/tree/devns Or use the Upgrade module: https://github.com/ryancramerdesign/ProcessWireUpgrade to get it.
    2 points
  4. On github there's the branch devns, which holds all the 3.0 changes: https://github.com/ryancramerdesign/ProcessWire/tree/devns
    2 points
  5. Ok guys, thanks! I've been there before, but was stuck seeing 2.7 everywhere, so.... err... thanks again, Now on track, Julio
    1 point
  6. There is a little info on SaveReady here: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/Pages.php#L2293 With save you need to be careful you don't end up going recursive which can happen when hooking after save because your hook function then needs to call save again, which triggers the hook again Maybe hookbefore save would be ok - I don't actually recall - I just tend to default to saveReady because it usually suits my needs!
    1 point
  7. Thanks for making this Adrian. Just used it for the first time and worked great
    1 point
  8. Shouldn't be too hard to incorporate into the core. Meanwhile, I've tweaked together a tiny module that adds a delete button next to the crop icon. It's not really tested with different permission settings though. github repo for ImageActionDelete
    1 point
  9. @adrian thanks! I've found one more solution that addresses own Q and does not require code. It is as simple as (1) setting "Don't allow unpublished pages" in template advanced settings and (2) adding role-publish permission in template access tab. As a result, there are no unpublished pages => no "pub/unpub" buttons while user in role is allowed to edit published pages.)
    1 point
  10. Kixe, I have installed your logger, so it will be interesting to see what it kicks out. I know wp-admin is the most common one, but I don't think it is all of them. Nice tool.
    1 point
  11. I just looked at this, as umlauts and other funny characters in URL paths are going to be on the table in one of my next work-related PW tasks next year, and I'm pretty sure that FieldtypeURL currently ignores all assigned textformatters. I've already filed a bug. Also, HTML Entity Encoder is probably the wrong tool for that task. The way to go would IMHO be to rawurlencode all path components in the URL, encoding all non-reserved non-ascii characters to their percent encoding in line with RFC 3986.
    1 point
  12. In relation to lister - So i have this module generating a dynamic link (the link is based off the combination of a page select and some attributes of the page being edited); to get it to work in lister, e.g. where it doesn't end up getting entity encoded, i added this to ready.php: wire()->addHookAfter('FieldtypeRuntimeMarkup::markupValue', function($event) { $value = $event->arguments('value'); $event->return = $value; }); should the module assume that the output will be markup and therefore also provide a markupValue by default, or leave this up to the user to add as a hook?
    1 point
  13. I just added a couple of new options to this module that allow for automatic protection of unpublished and hidden pages and their children. I am finding the unpublished protection very handy as I can set the parent of a branch to unpublished while it is being developed. With this option enabled, I can send the link to this page direct to clients and they will be presented with the custom login form so they login and then immediately view the page - no need to go via the backend admin panel (just like the normal way this module works), and they won't get the 404 page if they attempt to visit when logged out. Because children can also be protected there is no worry about someone guessing the URL to subpages, the entire branch is protected based on the publication status of the parent. Once the branch is ready to be published, simply publish and it will be live and the protection is removed - no need to give clients access to the control of this module on the settings tab and explain how they work. Hope you all find it useful!
    1 point
  14. Today I've created a really simple little module that is configurable and attaches to hooks. So it has more or less everything of a real world module in it. I thought processwire beginners would be interested in reading how to create such a module so I added some comments to the source code in a way the module should explain itself... Here it is: /** * BackgroundChanger module for demonstration purposes * * Demonstrates the Module interface and how to add hooks in a more real world manner... * * ProcessWire 2.x * Copyright (C) 2014 by Domenic Helfenstein * */ class BackgroundChanger extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( /* * the __("text") methods are used for multilanguage support * see: https://processwire.com/api/multi-language-support/code-i18n/ */ 'title' => __('BackgroundChanger'), 'summary' => __('This is a simple real world module that can change the background color.'), 'version' => 105, /* * autoload must be true if the module depends on hooks * see: http://wiki.processwire.com/index.php/Module_Creation#Details_of_what_the_.22autoload.22_property_means */ 'autoload' => true, /* * it is wise to run modules in singular mode when using hooks * see: http://wiki.processwire.com/index.php/Module_Creation#Details_of_what_the_.22singular.22_property_means */ 'singular' => true, ); } public function __construct() { //set default values $this->backgroundColor = 'yellow'; /* * !!! the value in the db will be automatically injected into this var * because it is named equal to the value of $field->name in * getModuleConfigInputfields !!! */ } public function init() { // add a hook after each page is rendered and modify the output $this->addHookAfter('Page::render', $this, 'changeBackground'); } public function changeBackground($event) { $page = $event->object; //do only modify non-admin pages if($page->template == 'admin') return; $extension = <<< _OUT <style> body {background-color:{$this->backgroundColor};} </style> _OUT; $event->return = str_replace("</head>", $extension."</head>", $event->return); } public static function getModuleConfigInputfields(array $data) { //create a fieldset $inputfields = new InputfieldWrapper(); //create field for background color $field = wire('modules')->get('InputfieldText'); $field->name = 'backgroundColor'; $field->label = __("Enter the hex-code or name of the desired background color. (visit colorpicker.com)"); //if there is already a value stored, set this value to the field if(isset($data['backgroundColor'])) $field->value = $data['backgroundColor']; //add the field to the fieldset $inputfields->add($field); //return the fieldset to display return $inputfields; } } I hope this helps others creating their own modules! BackgroundChanger.module
    1 point
  15. @Ryan: looks like I made a mistake somewhere; can't repeat my earlier results either. It definitely looks like it was CKEditor that kept stripping that class after all. This time I'm having problems with extraAllowedContent though -- it doesn't seem to affect anything no matter what I do; tried all the examples you posted and nothing works. Right after adding "allowedContent => true" class stays, but without that it disappears as soon as the field gets focus. Any idea what could be causing this? Edit: extraAllowedContent is definitely sent to CKEditor. At the moment that specific editor instance has editor.config.extraAllowedContent set to "pre[class]", but still for some reason class is removed. Strange. Edit 2: Got it.. pre[class] isn't enough, it needs to be pre[class](*). It's working now
    1 point
  16. You have to enable it in your Form Builder module settings: InputfieldFormBuilderFile. On an existing FormBuilder installation, you may have to install the module before you can enable it. The $e['file'] should be an array of filenames. In the case of a single file, it would just be an array of 1 file. The actual file URL is protected from direct access, so you have to ask Form Builder to generate one for you. It's not the prettiest in terms of API access, but I think this should work: $form = $forms->get('contact-form'); foreach($form->entries()->find() as $entry) { foreach($entry['file'] as $filename) { $path = $form->entries()->getFilesPath($entry['id']); $url = $forms->getFileURL($form->id, $entry['id'], $path . basename($filename)); echo $url . "<br />"; } } Regarding submission date, Soma is correct that it would be contained in $entry['created']; as a unix timestamp.
    1 point
  17. Grüezi Daniele, you will get access to the form builder support forum once Ryan sees this. I'm not sure what you need to archive, but since the entries are stored as json you can't search for entry fields. If you want to use API to find entries you need to store them as pages. You can access the entries in DB through $forms foreach($forms->get("contact-form")->entries->find() as $e){ echo "<p>{$e['e_mail']}</p>"; }
    1 point
  18. Not technically a supported feature at present, but I think you can get the result you want. You'd take a query like this: $pages->find("body*=something"); and convert it to this: $pages->find("body.data{$user->language}*=something"); That should return just the pages that match the current user's language, rather than including the default language.
    1 point
×
×
  • Create New...