PWaddict

Members
  • Content count

    483
  • Joined

  • Last visited

Community Reputation

240 Excellent

About PWaddict

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

1,667 profile views
  1. The following hook should do what you want. It's based on old @Soma's post. All you have to is to edit $myslug with your random hash generator. $wire->addHookBefore("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments[0]; if ($page->template->name != 'news-article') return; foreach ($this->languages as $lang) { $lname = $lang->isDefault() ? '' : $lang->id; $default = $this->languages->get("default"); $myslug = '-myslug'; if ($page->title->getLanguageValue($lang)) { $page->set("name$lname", $page->title->getLanguageValue($lang) . $myslug); } else { $page->set("name$lname", $page->title->getLanguageValue($default) . $myslug); } } });
  2. PWaddict

    @kixe The 175 line of the module is causing the issue: if (wire('fields')->get($format) && wire('fields')->get($format)->type instanceof FieldtypeOptions) $value = $page->get($format)->get('value|title'); I had to change this to this in order to get the title of the options field: if (wire('fields')->get($format) && wire('fields')->get($format)->type instanceof FieldtypeOptions) $value = $page->get($format)->title; Additional languages for the options field are ignored cause I'm only getting the default one for all page names. Please check it out and update the module. Thanks.
  3. PWaddict

    @kixe I want to use an Options field as part of the pagename but I don't get anything. On the Name format for children I tried with: title my_options_field and with title my_options_field.title but I only get the pagename from the title field.
  4. In your selector add sort=sort.
  5. PWaddict

    Here is how I did it: $wire->addHookAfter("Pages::save", function(HookEvent $event) { $page = $event->arguments[0]; if($page->template->name != 'my-template') return; $admin_page_name = wire("pages")->get(2)->name; $repeater_id = wire("fields")->get('my_repeater_field')->id; $empty_items = $pages->find("template=repeater_my_repeater_field, my_text_field='', parent=/{$admin_page_name}/repeaters/for-field-{$repeater_id}/for-page-{$page->id}/, include=all"); if(count($empty_items)) { foreach($empty_items as $empty_item) { $page->of(false); $page->my_repeater_field->remove($empty_item); $page->save(); } }
  6. I would like to auto remove repeater items if a text field inside repeater item is empty. The below code placed inside the template removes the specific repeater items when someone visits the page. How can make it work in a Hook when the editor saves the page on backend? $admin_page_name = $pages->get(2)->name; $repeater_id = $fields->get('my_repeater_field')->id; $empty_items = $pages->find("template=repeater_my_repeater_field, my_text_field='', parent=/{$admin_page_name}/repeaters/for-field-{$repeater_id}/for-page-{$page->id}/, include=all"); foreach($empty_items as $empty_item) { $page->of(false); $page->my_repeater_field->remove($empty_item); $page->save(); }
  7. Has anyone figured this out? I really need this hook.
  8. PWaddict

    I've never output repeater content outside from their pages so maybe I'm not the right guy to help you. Until someone else can reply you should check the Repeater demonstration page on the part "Finding pages by repeater value (using selectors)".
  9. PWaddict

    Try the below but on the template enter the name of the repeater template. If you go to "Setup > Templates > Filters > Show system templates? > Yes" you'll find that your repeater field has a template like this: repeater_your_event_repeater: $upcoming_dates = $pages->find("template=repeater_your_event_repeater, agenda_datum>=$today, sort=agenda_datum, limit=3");
  10. PWaddict

    Sorry my mistake. The selector code if placed on another page must be $pages->find. Try this: $upcoming_dates = $pages->find("template=your_event_template, agenda_datum>=$today, sort=agenda_datum, limit=3");
  11. PWaddict

    @tooth-paste Of course just add a limit on your selector like this: $upcoming_dates = $page->agendaitem->find("agenda_datum>=$today, sort=agenda_datum, limit=3");
  12. PWaddict

    I think it depends on the content.
  13. PWaddict

    @wbmnfktr Repeater items are actually pages too. @tooth-paste Here is how you can do it: <?php if(count($page->event_repeater)) { $today = strtotime("today"); $upcoming_dates = $page->event_repeater->find("event_date>=$today, sort=event_date"); if(count($upcoming_dates)) { foreach($upcoming_dates as $upcoming_date) { ?> <div>...</div> <?php } } } ?>
  14. Is there any difference between these? Aren't they doing exactly the same thing? if($page->template == 'admin') return; if($page->template->name == 'admin') return;
  15. To easily add rel="next" and rel="prev" tags for pagination in head section insert the following hook to your site/ready.php: $wire->addHookAfter('Page::render', function(HookEvent $event) { $page = $event->object; if($page->template == 'admin') return; $tags = ''; $config = wire('config'); if($config->urls->httpNext) { $tags .= "<link rel='next' href='{$config->urls->httpNext}'>"; } if($config->urls->httpPrev) { $tags .= "<link rel='prev' href='{$config->urls->httpPrev}'>"; } $event->return = str_replace("</head>", $tags . "</head>", $event->return); });