pogidude
Members-
Posts
122 -
Joined
-
Last visited
Everything posted by pogidude
-
yeah which is what confused me.. since they both added the inputfield at the *end*. so you're basically saying I just take my pick between the two?
-
I'm working with inputfields and saw in core/InputfieldWrapper.php file the add(), append() and other related methods. I tested both and came out the same: $modules = $this->modules; //$this->setFuel('processHeadline', 'Content Flow Here'); $form = $modules->get('InputfieldForm'); $field = $modules->get('InputfieldMarkup'); $field->label = $this->_('My Markup'); $field->attr('value', '<h4>Not my markup content</h4>'); $field2 = $modules->get('InputfieldMarkup'); $field2->label = $this->_('Second Markup'); $field2->attr('value', '<h4>Not my markup content</h4>'); $wrapper = new InputfieldWrapper(); $wrapper->attr('title', 'Wrap Title'); $wrapper->attr('description', 'Wrapp'); $wrapper->add($field); $wrapper->append($field2); $form->append($wrapper); //$form->append($field2); return $form->render(); so, my question is, what's the difference between the two? and when should I use one over the other?
-
I'd like to add the table tools plugin to ckeditor. I've already tried adding "tabletools" to the list of Extra Plugins under CKEditor settings. also tried adding "TableTools" in the CKEditor Toolbar. nada I can see that the ckeditor module already has tabletools so not sure what I need to do to activate this plugin. Thanks! EDIT: Finally found out that the table tools plugin doesn't add anything to the toolbar. You right click on the table to get the context menu (slap forehead)
-
I'd like to report an issue: Here is screenshot of what I get when I click on the Profile link. Do duplicate the issue: 1. Create new field with type CropImage 2. Assign this field to the "user" template (system template) 3. Go to Modules -> User Profile module. 4. Check the new field you created so that it will show up in the Profile screen. 3. Click on Profile link - right beside Logout. You should be able to see the Profile screen... for now. 4. Now upload a new thumbnail. 5. Save. 6. Meet the screenshot above. This is the list of site modules I have installed: AdminBar AfterSaveActions FieldtypeCropImage FieldtypeTemplates.module MarkupTwitterFeed ModulesManager PageEditFoldStatus PageEditPerRole PageEditPerUser PageListPin PagesCreatedEdit.module ProcessLatestComments ProcessPageDelete ProcessSelectorTest README.txt TextformatterVideoEmbed Everything goes to normal if you uncheck the thumbnail field from displaying in the User Profile config module.
-
Hi Ryan, this is basically the kind of "selector" I was looking for. An OR selector something that looks like this: $page->children("date<=$now|date=0"); I guess will have to do a manual query for something like this like you said. Thanks! The paging functions you mentioned are interesting. Still not very sure how the pager is created here.. will have a separate thread of questions for those
-
Here is screenshot of what I get when I click on the Profile link. Do duplicate the issue: 1. Create new field with type CropImage 2. Assign this field to the "user" template - I assume you know how to show system templates 3. Go to Modules -> User Profile module. 4. Check the new field you created so that it will show up in the Profile screen. 3. Click on Profile link - right beside Logout. You should be able to see the Profile screen... for now. 4. Now upload a new thumbnail. 5. Save. This is the list of site modules I have installed: AdminBar AfterSaveActions FieldtypeCropImage FieldtypeTemplates.module MarkupTwitterFeed ModulesManager PageEditFoldStatus PageEditPerRole PageEditPerUser PageListPin PagesCreatedEdit.module ProcessLatestComments ProcessPageDelete ProcessSelectorTest README.txt TextformatterVideoEmbed Everything goes to normal if you uncheck the thumbnail field from displaying in the User Profile config module.
-
I have an announcement template with the following date fields: - publish_date - expire_date The idea is to show announcements that should be be published by now (exclude pages whose publish date is still in future) and whose expire_date is not yet due. Also, if the expire_date is not filled out, then it means the page has no expiration. That last condition is what's stumping me. If all pages has both publish_date and expire_date then no problem since we can do a find like this: $announcements = $page->children("expire_date>$now, publish_date<=$now"); where $page in this case is the parent for all announcements. Oh yeah, that line was taken from this thread. Thanks! Unfortunately, that snippet won't return pages with empty expire_date My solution is this: $now = time(); $all = $page->children("date<=$now,limit=20"); //get all expired announcements $expired = clone $all; $expired->filter("expiration_date<$now,expiration_date>0"); //remove all expired announcements //$announcements = $all->remove($expired); $all->filter("id!={$expired}"); unfortunately, this messes up paging in some way. This is my full code: function renderAnnouncements($page){ $now = time(); $all = $page->children("date<=$now,expiration_date>$now"); //get all expired announcements $expired = clone $all; $expired->filter("expiration_date<$now,expiration_date>0"); //remove all expired announcements //$announcements = $all->remove($expired); //$all->filter("id!={$expired}"); foreach($all as $p){ if(empty($p->summary)) { // summary is blank so we auto-generate a summary from the body $summary = strip_tags(substr($p->body, 0, 450)); $p->summary = substr($summary, 0, strrpos($summary, ' ')); } } $t = new TemplateFile(wire('config')->paths->templates . '/markup/announcements.php'); $t->set('announcements', $all); $out = $t->render(); // if there are more annoucements than the specified limit, then output pagination if($all->getLimit() < $all->getTotal()) $out .= $all->renderPager(); return $out; }
-
per my question: ryan and soma's answer is exactly what I needed (soma's answer is more detailed though ) yeah I've mixed things up since I've been trying to make a connection between what inputfields are useable on certain fieldtypes. when I saw that fieldtypePage had multiple alternate inputfields, then I assumed that fieldtypeText had multiple alternates as well - i.e. email, pagename, pagetitle - they're all text fields. anyway, I did end up using just the regular text field and used Sanitizer::names() to sanitize the input to role_permitted_templates field. thank you both.
-
just thought to tell you Ryan that everything *clicked* today. basically, what you were saying was, "create a Template Select input field module and use that for my other module" right? of course I don't have to do that anymore with Hani's module + dependencies but this definitely was lightbulb moment for me thanks
-
never mind. I get it now. just tried setting the labelFieldName to 'title' on a FieldtypePage and got the list shown on the field showed titles instead of paths. very cool
-
hi @WillyC, how do these fieldtypes tell what input they use? is what I'm asking.. for example, there's FieldtypeCheckbox, then there's InputfieldCheckbox and InputfieldCheckboxes. Based on my tests, I can use InputfieldCheckbox on FieldtypeCheckbox but not InputfieldCheckboxes. Another example, I want to use InputfieldPageName or InputfieldName, is that possible? appreciate your help. thanks
-
On a similar though, how do I know which Inputfield a Fieldtype can use? like how $field_addable->type = wire('modules')->get('FieldtypePage'); can use $field_addable->inputfield = 'InputfieldPageListSelectMultiple'; and I'm pretty sure $field_addable->inputfield = 'InputfieldPageListSelect';
-
Thanks!
-
Thanks Ryan. I'm still trying to get the hang of using the different fields in PW - which Inputfield a Fieldtype can use or something like that. Basically, I'd like to use the text field used for creating page names, which is why I used InputfieldPageName, because of it's sanitizer. So, what you're saying is, there's no way I can use InputfieldPageName in this situation?
-
So if my field was: $field_templates = new Field(); $field_templates->name = 'role_permitted_templates'; $field_templates->label = 'Templates users with this role may use on pages they can add to'; $field_templates->labelFieldName = 'path'; $field_templates->type = wire('modules')->get('FieldtypeText'); $field_templates->inputfield = 'InputfieldPageName'; I don't need to specify the labelFieldName since this is basically just a text field right?
-
ProcessPageAdd::getAllowedTemplates() weird...
pogidude replied to pogidude's topic in API & Templates
actually, the issue here is basically what I started on this thread http://processwire.com/talk/topic/3855-pagearray-field-in-a-role-doesnt-have-anything-when-adding-a-page/ I didn't know they were related at that time thus the separate thread. As you can see from this reply I made and comparing it to my reply above, what I'm pointing out is that the template dropdown *worked* when I added this: foreach($this->user->roles as $r){ if(count($r->role_editable_pages)){ error_log('=== #pages: '.count($r->role_editable_pages). ' template: '.$r->name); foreach($r->role_editable_pages as $e){ error_log('===== page name: '.$e->name); } } } which is now the foreach line I now use in my module foreach($this->user->roles as $r){ $r->role_editable_pages; } -
hmmmm.. now I'm getting it.. thanks! how do I check for module dependencies in my module? I'd like to notify user to install Hani's module if it's not yet installed.
-
Thanks Ryan. I originally thought of asking for User::hasPermission() to be hookable for the module I've been working on but I think asking for ProcessPageAdd::getAllowedTemplates() would be more useful. So, can I ask for ProcessPageAdd::getAllowedTemplates hook? Thnaks!
-
PageArray field in a role doesn't have anything when adding a page
pogidude replied to pogidude's topic in General Support
Hi Ryan, Thanks for chiming in. Yes I'm getting 1 fewer pages in role_editable_pages, but ONLY when I add a new page. which is when this line $parentEditable = $this->parent->editable(); runs in the ProcessPageAdd::getTemplates() method. Editing pages is no problem. But, I don't think it's the pop() thing because the first time I noticed this issue was when i only had 1 page assigned to the role_editable_pages field. Which means it wasn't going through this: $editable_pages = $role->role_editable_pages; if(count($editable_pages)){ ..... CODE BELOW ... because $editable_pages now had 0 pages in it (instead of 1 page). and oh, the pop() thing only runs when scan_ancestors is enabled - which I hadn't. What I did notice was if I access the role's "role_editable_pages" field before $this->parent->editable() is called with something like this: foreach($this->user->roles as $r){ $r->role_editable_pages; } things worked as expected. So, what I did was I hooked before ProcessPageAdd::execute() and just ran that foreach loop.. see workaround https://github.com/ryannmicua/PageEditPerRole/blob/master/PageEditPerRole.module#L244 Oh yeah, if you're going to test out the plugin, you'll have to make ProcessPageAdd::getTemplates() hookable. I've been mulling over how to do this for 3 days without hacking core but really saw no way. -
I'm not so sure I just tested out the module to confirm what I thought. Here's what the module does. 1. It only does it's thing if the user has the role *editor*. 2. It allows users with the role *editor* to edit only their own pages - pages that they created. 3. To reiterate #1, module doesn't do anything if the user doesn't have the editor role. Now, before I continue I'd just like to say that I've already found a use for this module - restricting certain users to edit only their own pages. and it kind of solves part of a problem I had with my PageEditPerRole module.. So, thanks Soma Continuing, I believe what Peter was asking for was: 1. Users can only edit their own pages. (pages they created) 2. If the user has an *editor* role, then they can edit other people's pages. I think #1 can be improved to say that "users with role *author* can edit only their own pages". Then, there would be another role check for the *editor* role (or something similar) who can edit everything. As below: <?php /** * Page edit per user created id * */ class PagesCreatedEdit extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Pages created edit', 'version' => 1, 'summary' => 'Page edit only for created pages by user', 'href' => '', 'singular' => true, 'autoload' => true, ); } public function init() { // add edit permission hook for admin pages $this->addHookAfter('Page::editable', $this, 'editable'); } public function editable($event){ $page = $event->object; //I don't think we should stop users if they already have permission to edit //Permissions should be additive IMHO - other modules could grant edit permission. if($event->return) return; //I'm not too good with this kind of conditionals. basically, stop if user doesn't have either of these roles //The idea is, the presence of these roles trigger when this module *runs* - does it's permission check //(obviously the module is already running) if(!$this->user->hasRole("author") && !$this->user->hasRole('editor')) return; /** TODO: author and editor roles may be another name or could be multiple roles **/ //get highest "role type" $roles = $this->user->roles; $is_editor = false; //probably don't need this foreach($roles as $r){ if($r->name == 'editor'){ $is_editor = true; $role = $r; break; } elseif( $r->name == 'author' ){ $is_editor = false; $role = $r; } } //make sure role has page-edit permission. I know user may have page-edit permission from another role. //but let's not consider that for now. if(!$role->hasPermission('page-edit')) return; if($is_editor){ $event->return = true; }elseif( $page->created_users_id == $this->user->id ){ $event->return = true; } /** * Caveats: (for now) * * If user has both author and editor roles, then this module will use the editor role for permission check. * This means if editor role doesn't have page-edit permission, user won't get permission even if author * has page-edit permission. */ /* if($event->return) { // only if edit rights are true if($page->created_users_id == $this->user->id){ $event->return = true; } else { //don't think we need to set to false //$event->return = false; } } //*/ } }
-
Hi Soma, Would just like to know what the idea behind this code: public function editable($event){ $page = $event->object; if(!$this->user->hasRole("editor")) return; if($event->return) { // only if edit rights are true if($page->created_users_id == $this->user->id){ $event->return = true; } else { $event->return = false; } } } Why stop if the user doesn't have the "editor" role? Am I correct in thinking that this module targets only *editors* (or other roles specified in the code) and only allows them to edit their own pages?
-
Just pushed out an update to the module on github https://github.com/ryannmicua/PageEditPerRole and thought I'd ask for feedback. I did hack core though. The module needs ProcessPageAdd::getAllowedTemplates() to be hookable - required for #2 below. Right now, you can do the following: Select pages that role can edit. (I'll just say "role" instead of "users with role" but hope you understand) Select pages that role can add child pages to. requires the parent page to be editable by role (set in #1) and in module config, requires permissions to be considered further up the branch - if you don't, you can't edit the child page after you add. Next: - Improve #2. I'm thinking of adding another field - "Parent page where role can edit child pages". This is for situations where you'd like to allow users to create pages under a parent but not allow them to edit the parent page. This way, you don't have to enable the permissions to be considered further up the branch in module config.
-
In my module's install() method, I got this: //add role_permitted_templates $field_templates = new Field(); $field_templates->name = 'role_permitted_templates'; $field_templates->label = 'Templates users with this role may use on pages they can add to'; $field_templates->labelFieldName = 'path'; $field_templates->type = wire('modules')->get('FieldtypeText'); $field_templates->inputfield = 'InputfieldPageName'; $field_templates->description = 'Select the templates that users with this role can use when adding child pages.'; $field_templates->save(); $this->message("Added field 'role_permitted_templates' to the role template."); $fieldgroup = $this->fieldgroups->get('role'); $fieldgroup->add($field_templates); $fieldgroup->save(); Basically, I'd like to show a text field that sanitizes like the page name field (alphanumeric + dashes + underscore only) but my text field works just like a regular text field i.e. accepts spaces
-
ahhh.. thanks! I do like fuel().. it sounds awesome
-
in modules, I see code like this: $user = $this->user; and sometimes like this: $user = $this->fuel('user'); when should I use which?