Jump to content

PWaddict

Members
  • Posts

    926
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by PWaddict

  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. @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. @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. 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(); } }
  5. 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(); }
  6. 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)".
  7. 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");
  8. 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");
  9. @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");
  10. @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 } } } ?>
  11. 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;
  12. 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); });
  13. Try to install a fresh copy of PW to the server you have the issue and during installation PW will let you know if your server is properly configured.
  14. When you moved the files on the server did you also moved the folders cache, logs & sessions from site/assets/ ? If yes then I suggest you to DELETE those folders. This could be the problem.
  15. The Inputfield Dependencies page doesn't say anything about the published status so I guess it isn't possible. You might be able to do what you want with a hook.
  16. Using this it properly works: $today = time(); $news_posts = $page->children("limit=10, news_date<=$today");
  17. Using the following selector I should be able to get today's and past posts but I'm only getting the past ones. $news_posts = $page->children("limit=10, news_date<=today"); If I change the operator to >= then I get today's and upcoming posts but why the <= doesn't display today's posts too?
  18. On the PW 3.0.104 version we get the field labels instead of the field names on "Missing required value", "Restored previous value" and "Page unpublished because field is required" error messages. More info on GitHub.
  19. On the PW 3.0.104 version we get the field labels instead of the field names on "Missing required value", "Restored previous value" and "Page unpublished because field is required" error messages. More info on GitHub.
  20. I forgot to update the topic. On the PW 3.0.104 version we get the field labels instead of the field names on "Missing required value", "Restored previous value" and "Page unpublished because field is required" error messages. More info on GitHub.
  21. It should be src="https://www.youtube-nocookie.com/embed/abc123?feature=oembed&rel=0" in order to work. It seems that TextformatterVideoEmbedOptions module can't add the options to your custom TextformatterVideoEmbed module. Install the original TextformatterVideoEmbed module and you'll see that the "rel" will be added properly.
  22. As I said above you can easily hide them by changing the "YouTube: Show Related Videos at the End" to 0 value. This adds the "rel=0" to the embed url which hides both pause and end related videos. I've already tried and it's working fine.
×
×
  • Create New...