-
Posts
10,902 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
Yes, what I just wrote is a module that can be installed directly so long as you tweak those few things I mentioned to suit your needs. Well, you can easily install the comments module (http://processwire.com/api/fieldtypes/comments/) - it's in the core, just not installed by default. Adding the comments field to the template for the newly added pages and including the appropriate code in the template's php file as per the instructions in that link will get your comments set up automatically. As for images - not sure the best approach here. You might be able to extend the comments fieldtype, but it might be better to go with a completely custom front end form. Here is the seminal thread on the matter of creating front end forms (https://processwire.com/talk/topic/2089-create-simple-forms-using-api/) - it is fairly simple, but you will have to get your hands dirty. You might be able to use Ryan's pro Form Builder module (http://processwire.com/api/modules/form-builder/) which does include the ability to upload images. I haven't really ever used it though, so not sure exactly what would be involved in submitting the form and having it populate the same page again, especially if multiple users will be contributing content to the same page. I think a custom front end form is probably the best option in the end and I have used these many time for user submitted images. I am sure others will chime in with additional ideas on this front though.
-
Hi yabapolido and welcome to the forums. This should do it, although you'll need to tweak the preg_match because I wasn't sure whether you wanted exactly 2 numbers and two letters, or just a minimum of each. Currently it is set to just two of each. Also, this currently only works if you are talking about a page added to the root of your site, but this can be easily tweaked. The other thing you'll want to adjust is the template being assigned to the new page - currently I set it to basic-page. <?php /** * ProcessWire Auto Create Page * by Adrian Jones * * Automatically creates a page if it doesn't exist * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class AutoCreatePage extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Auto Create Page', 'summary' => 'Automatically creates a page if it does not exist', 'version' => 1, 'autoload' => true, 'singular' => true ); } /** * Populate the default config data * */ public function __construct() { // determine the URL that wasn't found $url = $_SERVER['REQUEST_URI']; // if installed in a subdirectory, make $url relative to the directory ProcessWire is installed in if($this->config->urls->root != '/') { $url = substr($url, strlen($this->config->urls->root)-1); } $last_slash = strrpos('/', $url); $this->last = str_replace("/","",substr($url, $last_slash)); } public function init() { if (preg_match( '/^(?=.*[a-zA-Z].*[a-zA-Z])(?=.*\d.*\d).{4}$/', $this->last)) { $this->addHookAfter('ProcessPageView::pageNotFound', $this, 'createPage'); } } public function createPage($event) { if(!$this->pages->get("parent=1,name={$this->last}")->id){ $np = new Page(); $np->parent = $this->pages->get("/"); $np->template = 'basic-page'; $np->title = $this->last; $np->of(false); $np->save(); $this->session->redirect($np->url); } } }
-
This is incredibly rough, but throw this at the end of your main.php/main.inc/foot.inc or whatever you are using: if($user->isSuperuser()){ $fieldinfo = '<hr /><p>Field details for ' . $page->template . ' template</p>'; $fieldinfo .= '<table><th>Name</th><th>Label</th><th>Type</th>'; foreach($page->fields as $field){ $fieldinfo .= '<tr><td><a href="'.$config->urls->admin.'setup/field/edit?id='.$field->id.'" target="_blank">'.$field->name.'</a></td><td>'.$field->label.'</td><td>'.$field->type.'</td></tr>'; } $fieldinfo .= '</table>'; echo $fieldinfo; } This will give you a table of fields for the current template including name, label, and type. The name cell links to the edit page for the field if you need more info. I am actually thinking it make be nice to add the popup of field settings the way soma did it in https://github.com/somatonic/HelperFieldLinks which is a module you should definitely install by the way
-
It is definitely possible to set up a permission for modules. Actually, that might be a nice addition to the Redirects module. It's simply a matter of setting the permission required in the module config and then giving a role that permission. I was just going to suggest the batcher module. Here is how it is implemented: https://github.com/wanze/ProcessBatcher/blob/master/ProcessBatcher.module#L58 Then typically the module adds that permission when it installs. EDIT Perhaps you should make those changes to Redirects and submit a Pull Request!
-
Hey davo - nice work! I am curious - I think I might be missing something - what advantage does this have over apeisa's Redirects module? http://modules.processwire.com/modules/process-redirects/
-
You could set up a page field with a PageListSelectMultiple Inputfield Type - the user could choose the pages from anywhere in the page tree and sort as desired. Is that what you are wanting to do?
-
Well the first thing is to make sure that isGuest() is working, so do something simply inside it like: echo "true". When you used isLoggedin() did you get the case correct? Then if that works you know it's an issue with your cookie code. It seems strange to me to use a date format as the cookie name and then isset for a cookie named "pageid". Is that all intentional?
-
https://processwire.com/talk/topic/4680-block-access-to-settings-delete-and-view-tabs-for-page/
-
Should be working again in the latest PW dev version: https://github.com/ryancramerdesign/ProcessWire/commit/52ac6b7a647c212afbc07446847743d21b862164 Thanks Ryan!
-
https://processwire.com/talk/index.php?app=core&module=usercp&tab=core&area=notifications You should be able to configure what you are looking for in the first item?
-
Yep - same field names including "date". Hopefully Ryan can help you debug this one.
-
No issues here - perhaps it might be best to post this question in the VIP board for pro fields for Ryan to investigate. Do you have the same issue with other table fields? Does it make a difference if the table rows are created via the admin or via the API?
-
No stupid questions here Andrea - we are all learning Enjoy your PW discovery - it's a whole new world!
-
Hi @a.masca and welcome to the forums. Don't mess around with Hanna for videos: http://modules.processwire.com/modules/textformatter-video-embed/ And this for google maps: http://modules.processwire.com/modules/textformatter-google-maps/
-
Looks great - thanks! Also check out this solution from diogo: https://processwire.com/talk/topic/6196-easy-search-on-pw-forums-with-google/
-
Just wanted to note that this module won't work on recent dev versions of PW due to the inability to upload SVGs anymore. I have filed an issue here: https://github.com/ryancramerdesign/ProcessWire/issues/597
-
Oh I see - if I understand correctly I think module might help you out: http://modules.processwire.com/modules/page-edit-field-permission/
-
I think you might have found a hidden feature there Actually not hidden - the instructions mention you can do that - the ability to create multiple templates with space separated names But Nico is saying to use the Label field - this is collapsed by default and only available once the template has already been saved.
-
I have done something like this for a form where the user can choose from a bunch of options, but if they choose "other", they can add an option to a text field. When the form is submitted, the value from this field is added to the page field (and selected for their submission) so that it will be available for the next user filling out the form. Sounds like you need another level of control though if you want a front-end user to be able to edit the contents of the page field - is that the scenario you are after?
-
There is the label field of course - you can make this quite long and it is used when selecting a template for a page. Is that enough?
-
Yup, you can temporarily add it to a page, or you could bootstrap a special file for running scripts like this, or you could use the "Save and Test" option in Hanna Code, or even my Code Tester module.
-
I don't think this module can do that. But this small script can foreach($pages->find("template=people, title*=heart") as $p){ $p->of(false); $p->color = 'red'; $p->save("color"); } EDIT: Actually I don't think this module seems to be working. Does it require some table editing module/script to also be installed? I see that it requires MarkupAdminEditableTable - problem is that it doesn't seem to be initiating it? This is all I get:
-
This is what I use on a site. This was the second site I did with PW, so no guarantees that it is the most efficient way, but you can see how I am handling whitelisting with arrays. <?php if($input->get->filter_save || isset($input->get)) { // Search selector builder $search_string = ''; $current_field = ''; foreach($input->get as $field_name => $field_result){ if (is_array($field_result)){ foreach($field_result as $f_value){ $input->whitelist($field_name, $field_result); if($current_field == $pages->get($f_value)->template){ $search_string .= '|' . (int)$f_value; } else{ $search_string .= ',' . $pages->get($f_value)->template . '=' . (int)$f_value; } $current_field = $pages->get($f_value)->template; } } else{ if($field_name == 'search' && $field_result != ''){ $search_string .= 'title|headline|summary|body|notes%=' . $sanitizer->selectorValue($field_result); $input->whitelist('search', $sanitizer->selectorValue($field_result)); } elseif($fields->$field_name->type == 'FieldtypeDatetime' && $field_result != ''){ $search_string .= ',' . $field_name . '=' . $sanitizer->selectorValue($field_result); } } } $search_string = trim($search_string,','); } else{ $search_string = ''; }
-
I wonder if the Add Field dialog on the templates page could be enhanced to use the field's tags as optgroup dividers in the select field. I can see that might be useful if you have a lot of fields.
-
I am really not sure if this is the issue or not (in a hurry), but I have this same approach working, but I had to do this: $pagination = $filter_results->renderPager(array('arrayToCSV' => false)); See Ryan's post about it here: https://processwire.com/talk/topic/3472-enable-pagination-for-search-results/?p=38214 EDIT: I think you are also missing whitelist. Read about it here: https://processwire.com/talk/topic/1883-how-to-use-input-whitelist-with-checkboxes-or-any-array/