-
Posts
44 -
Joined
-
Last visited
Everything posted by didhavn
-
Hey all. I ran into a strange problem. I am using the module Export Site Profile to migrate from one server to another. I did this before and everything worked fine. With this page, I had a strange problem. The installation with the site-profile worked fine (except that I had to uncomment the "RewriteBase /" in htaccess to get to admin). The installed site modules (I installed most of them using ModulesManager) have been missing at first but got installed after refreshing the modules (Navbar: Modules -> Refresh). But once the modules are installed, I can not edit the Home-Page (page id=1, so root of pagetree) anymore. In firefox I get a blank page, Chrome at least shows a 500 Error. All other pages are editable as before, only Home stopped working. Does anyone of you has an idea what is happening there? Thanks a lot!!
-
Of course a BIG SPECIAL THANK to the fastes replying user in this forum..... kongondo !!
-
Thanks BitPoet, I was missing that!
-
I know how to access fields in general but the $fields variable is not defined inside the hook. And I did not manage to get it e.g. via the $event variable.
-
Hey All. I am trying to change the label of a field after a certain page is saved. This field is not part of the page that is saved but the label should be updated with the page name. $pages->addHookAfter('saved', function($event) { $page = $event->arguments[0]; if($page->template->name == 'service-type') { $cid = $page->id; $this->message($cid); /* find field servicetype_rangeslider_$cid and set label */ // how to access $fields?? } }); I have this hook in my /site/ready.php. Now my remaining problem is, how to access $fields array or in general, how to get the field? I am thankful for every hint, thanks!!
-
Prohibit 'view' of pages with certain template
didhavn replied to didhavn's topic in General Support
Thanks a lot adrain for the solution and the additional information, it works just perfect! This system is just great, especially the community! Thanks again! -
Prohibit 'view' of pages with certain template
didhavn replied to didhavn's topic in General Support
Hey LostKobrakai and adrian. Thanks a lot for your suggestions. The solution with the hook would be very elegant, unfortunetly I can not get it working. I placed the code-snipped in _init.php and all my section-templates do indeed start with section-* thus in principal it should work like proposed. I have little experience with hooks but I think the hook is not called at all because e.g. a $this->message('hook called') does not work. Any suggestions? -
Hey all. I have a question concerning templates and a possible setting to disallow/prohibit to view pages that are using certain templates. I have a couple of templates that are not complete page-templates including header/footer but are sections-templates. E.g. I have a template called 'Case' and every page using this template can add section children, e.g. first a section-video, then section-textblock, ... Doing this, the user can create its own cases out of building blocks. However, up to now one can select 'view' in the page-tree in the admin panel to view each sections. This view failes, as they don't have a header/footer. Can anyone of you think of solution how to disable that one can view pages with template section-* ? Thanks a lot in advance!
-
Hey all. I just created a new "Avatar" user-image field in the user-template. Unfortunately, it is only showing in 'Access->Users->user-xyz' and not in 'Wrench-Sign->Profile user-xyz', so on the page http://localhost/testsite/admin/profile/ Does anyone of you know what to change that this new field is also shown in the profile-page? Thanks a lot!
-
Hey all. I am trying to create an image-field from API. It is working fine, but opening the page with the new image-field leads to the following error: FieldtypeImage: Field "servicetype_image_1129" is not yet ready to use and needs to be configured. For all other fields I am creating in this module (e.g. checkbox, textarea)...everything is working without errors. This is my code to create the image-field: $f_img = new Field(); $f_img->type = $this->modules->get("FieldtypeImage"); $f_img->name = 'servicetype_image_' . $page->id; $f_img->label = $page->get('title')->getDefaultValue() . ' Service-Type Image'; $f_img->set('tags',$tag); $f_img->set('icon',$icon); $f_img->set('maxFiles', '1'); $f_img->set('noLang', 1); $f_img->set('adminThumbs', 1); $f_img->set("textformatters", array("TextformatterEntities")); $f_img->save(); Anybody an idea what is causing the problem? Thanks a lot in advance!!
-
FieldtypeTextareaLanguage - set 'Text Formatters' and 'Inputfield Type'
didhavn replied to didhavn's topic in API & Templates
I love this forum...you get help within minutes and can use the answers just out of the box!! Thanks a lot, Can and BitPoet, everything is working just fine! -
FieldtypeTextareaLanguage - set 'Text Formatters' and 'Inputfield Type'
didhavn replied to didhavn's topic in API & Templates
Hey Can and BitPoet. Thanks a lot of for the fast reply, I will test your solutions asap. Thanks! -
Hey All. I am creating a new field of type 'FieldtypeTextareaLanguage' via a module. Everything is working just fine expect that I can not find any information on how to set the 'Text Formatter' (to HTML Entity Encoder) and 'Inputfield Type' (to CKEditor). I tried the following which failed and was just a guess because of the IDs and select-values in the HTML... $f = new Field(); $f->type = $this->modules->get("FieldtypeTextareaLanguage"); $f->name = $newstcontentfieldname; $f->label = $newstcontentfieldlabel; $f->set('tags','servicetype'); $f->set('icon','fa-pencil-square'); $f->set('asmSelect0','TextformatterEntities'); $f->set('Inputfield_inputfieldClass', 'InputfieldCKEditor'); $f->save(); [EDIT] Furthermore, I just came across the question how to set the 'Visibility' --> ' Show this field only if' Option? Is there any documentation that I missed sofar about these field-variables and how to set them? [/EDIT] I am thankfull for any suggestion and hope somebody can help me. Thanks a lot!
-
Add field to specific position in existing template
didhavn replied to didhavn's topic in API & Templates
Aaaah, I didn't know that wire('templates') or $this->templates can be shown as an empty array in the $this->message output BUT still return something when doing foreach(wire('templates') as $t) { echo $t->name . '<br />'; } or $this->templates->get("name_of_other_template") Thanks a lot for your help, after realizing that, the rest was easy! <?php /** * ProcessWire module to create ServiceTypes by Pages * by Didhavn * 12.02.2016 */ class DidhavnAddServiceTypesByPage extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Add ServiceTypes By Page (Didhavn)', 'version' => 1.0, 'summary' => 'Add the ServiceTypes by getting Pages with Template "service-type"', 'singular' => true, 'autoload' => true ); } public function init() { $this->pages->addHookAfter('added', $this, "hookAdded"); } public function ready() { // PW API is ready, Controllers go here } public function hookAdded(HookEvent $event) { $page = $event->object; if (!$page->template) { $page = $event->arguments[0]; } if($page->template == 'service-type') { $newfieldname = 'servicetype_' . $page->name; $newfieldlabel = 'Service-Type ' . $page->get('title')->getDefaultValue(); $casetmpl = $this->templates->get("case"); $newfield = $this->fields->get($newfieldname); if (!$newfield && $casetmpl) { // field for this service-type doesn't exist -> create $f = new Field(); $f->type = $this->modules->get("FieldtypeRangeSlider"); $f->name = $newfieldname; $f->label = $newfieldlabel; $f->set('suffix','%'); $f->set('tags','servicetype'); $f->set('icon','fa-sliders'); $f->save(); // add field to template case $stsumfield = $casetmpl->fieldgroup->fields->get("servicetype_sum"); $casetmpl->fieldgroup->insertBefore($f, $stsumfield); $casetmpl->fieldgroup->save(); } } } } -
Add field to specific position in existing template
didhavn replied to didhavn's topic in API & Templates
I don't know why I get an empty Templates Object executing $this->message(wire('templates')); I can only get wire('pages'), nothing else. My module code is just this one class I posted above...nothing else. Maybe I have to implement some other classes? -
Add field to specific position in existing template
didhavn replied to didhavn's topic in API & Templates
Hey DaveP and adrian. Wow, I have heard that the PW community is fast and helpfull...but THIS fast? Thanks a lot, I will give it a try and hope that I will get is working. But a general questions remains....up to now, I wasn't able to get the list of templates in the module via e.g. $templates = wire('templates'); I need to add this field to a different template than the current and was only able to get this template via $currtmpl = $event->pages->find('template=case')[0]->template; Suppose I don't have a page with template case, this solution fails. Is there another possibilty to get the template 'case' without querying the pages? Thanks a lot!! -
Hey All. I am currently writing a very small module to accomplish the following: - I have a Page "Service Types" with multiple childs "Service Type". Whenever a new "Service Type" is added, a Field (in my case FieldtypeRangeSlider) should be generated, eg "servicetype_communication_rangeslider" and added to an existing template ('case') at a specific position. I have little experience with modules but managed to get it done till the successfull creation of the range-field. But now I am struggeling with adding it to the template. First, I havend managed to get a list of templates in the module..just a workaround via pages and selector template=case. I think this would work, but only of there are pages with this tempalte. If not, this solution fails and in general, I don't know how to get the templates in a module. Second, I have no clue how to add a field at a specific position to an existing template (to an existing Fieldset in my case). Here is my code so far: class AddServiceTypesByPage extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Add ServiceTypes By Page (Didhavn)', 'version' => 1.0, 'summary' => 'Add the ServiceTypes by getting Pages with Template "service-type"', 'singular' => true, 'autoload' => true ); } public function init() { $this->pages->addHookAfter('added', $this, "hookAdded"); } public function ready() { // PW API is ready, Controllers go here } public function hookAdded(HookEvent $event) { $page = $event->object; if (!$page->template) { $page = $event->arguments[0]; } if($page->template == 'service-type') { $f = new Field(); $f->type = $this->modules->get("FieldtypeRangeSlider"); $f->name = 'servicetype_' . $page->name; $f->label = 'Service-Type ' . $page->get('title')->getDefaultValue(); $f->set('suffix','%'); $f->set('tags','servicetype'); $f->set('icon','fa-sliders'); $f->save(); /* * now add the field to existing template with name 'case' */ } } } I am thankfull for any help or suggestion! Thanks a lot!