Jump to content

Zeka

Members
  • Content Count

    755
  • Joined

  • Last visited

  • Days Won

    6

Zeka last won the day on December 11 2018

Zeka had the most liked content!

Community Reputation

810 Excellent

About Zeka

  • Rank
    Hero Member
  • Birthday 04/12/1989

Profile Information

  • Gender
    Male
  • Location
    Kiev, Ukraine

Recent Profile Visitors

2,824 profile views
  1. @Guy Incognito AFAICS, this functionality relies on cookies. There is'repeaters_open' cookie which holds ID's of opened items. So, probably you can try to use https://processwire.com/api/ref/wire-input/cookie/ in hook to manipulates it.
  2. $allowed_fields = [ 'title', 'seo_title' ]; $out = $pages->find('include=all, limit=10')->explode(function($p) use($allowed_fields) { $fields = $p->fields; foreach($fields as $f) { if(in_array($f->name, $allowed_fields)) { return [ 'id' => $p->id, 'title' => $p->title ]; } } }); echo json_encode($out);
  3. @Noel Boss I'm using this code in hooks to Templatefile::render and didn't have any issues with it. if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return;
  4. Guys, I need some clarifications here. I'm building catalog menu and depending on whether a page has children with 'category' template I change some part of my selector. Code that I use: <?php namespace ProcessWire; $layout->setTemplate('sidebar'); $selector = [ 'template' => 'product', 'sort' => 'title', 'categories' => page('id'), 'limit' => 9 ]; if (page()->children->has('template=category')) { $selector['categories'] = page()->children('template=category')->add(page()); } $products = pages($selector); $sub_categories = page()->children('template=category'); bd(page()->children()); // 7 bd(page()->children('template=category')); // 8 As you can see in the first 'bd' I get 7 children and that is the right result. But it the second I get 8 children ( 7 children and current page which was added in if statement). I can't understand it from PHP side. For me, it's unintended behaviour as I'm calling function and waiting for a new result, but instead, I'm getting the result from an object from the previous call.
  5. @kkalgidim Not sure that it would suit your case, but worth to mention that there is the 'owner' selector, so you can use it instead of updating field. https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
  6. You don't have to write custom module, you can use ProcessPageEdit as process for that page and omit executeEdit method in your process module.
  7. @lokomotivan public function executeEdit() { // breadcrumb $this->fuel->breadcrumbs->add(new Breadcrumb($this->page->url, $this->page->title)); // Execute Page Edit $processEdit = $this->modules->get('ProcessPageEdit'); return $processEdit->execute(); } Probably you will use something similar for adding new pages, but with ProcessPageAdd. So, by using this aproach for adding new pages you will get an issue with initial languages values. As you can see all non-default languages are active. But, after page save they become disabled. I was trying to resolve this issue but with no luck. So I went with creating addition page under the module page which reffers to custom module which extend ProcessPageAdd class ProcessCustomPageAdd extends ProcessPageAdd { /** * @return array * */ public static function getModuleInfo() { return array( 'title' => __('Page Add', __FILE__), 'summary' => __('Add a new page', __FILE__), 'version' => 108, 'permanent' => true, 'permission' => 'page-edit', 'icon' => 'plus-circle', // 'useNavJSON' => true, ); } public function init() { if ($this->wire('page')->parent->name == 'news-manager') { $this->set('parent_id', 1036); } else { ..... } } } Hope it helps.
  8. @lokomotivan Not sure, but try to implement WirePageEditor by your module class class YourCustomLister extends Process implements WirePageEditor
  9. @Leftfield The path hook should be in ready.php and all logic should be in home.php or in the template file that you are using for root page. if (input()->urlSegment(1) && input()->urlSegment(2) == 'pr' && input()->urlSegment(3)) { $pagename = input()->urlSegment(1); $hash = $input()->urlSegment(3); $match = pages()->findOne("template=product, name={$pagename}, hash_field={$hash}"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } Also you should enable URL segment for root ( home ) page. Generate hash and save it to hash field you can by hooking in Pages::saveReady. You can find a lot of exaples in the forum.
  10. @Leftfield I think that URL segmetns is the way to go. wire()->addHook("Page(template=product)::path", function($e) { $page = $e->object; $e->return = "/{$page->name}/pr/{$page->hash_field}/"; }); Then you have to enable URL segments for your home template. And in template file if (input()->urlSegment(1)) { $pagename = input()->urlSegment(1); $hash = $input()->urlSegment(3); $match = pages()->findOne("template=product, name={$pagename}, hash_field={$hash}"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); }
  11. You can check whether page rendered in admin if so, do nothing. if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return;
  12. Ok, then public function ___execute() { $out = ''; $input = $this->wire('input'); $modules = $this->wire('modules'); $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", "form_application"); $btn_application_create = $this->modules->get("InputfieldSubmit"); $btn_application_create->attr('id+name', 'hook_accept_application'); $btn_application_create->value = "Start Student"; $btn_application_create->addClass("ui-priority-primary button_submit"); $form->append($btn_application_create); if ($input->post->hook_accept_application) { $form->processInput($input->post); if ($form->getErrors()) { $out .= $form->render(); } else { $this->addButtonsMethods(); } } else { $out = $form->render(); } return $out; } public function addButtonsMethods($event) { wire('session')->redirect(wire('pages')->get(123)->editUrl; }
  13. Hi @Federico Why just not check for input post like $modules = $this->wire('modules'); $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", "form_application"); if($this->wire('input')->post->your_submit_button) { $btn_application_create = $this->modules->get("InputfieldSubmit"); $btn_application_create->attr('id+name', 'hook_accept_application'); $btn_application_create->value = "Start Student"; $btn_application_create->addClass("ui-priority-primary button_submit"); $form->append($btn_application_create); }
  14. Definitely, I would recommend PW. In my case, the client didn't like the tree structure of pages, so I had to create separate Process modules for managing news, tags, banners, categories. I have found that it's much easier to control permissions and workflow via custom modules.
×
×
  • Create New...