Jump to content


  • Posts

  • Joined

  • Last visited

Community Answers

  1. Orkun's post in Manipulation of ProcessPageAdd / ProcessPageEdit Form in combination with language tabs was marked as the answer   
    Changed it completely, now it implements a little bit css with a hook inside InputfieldForm::render which does the magic of hiding and showing fields depending on language checkboxes. Since it's only a visual thing I removed the older hook where the languages get unpublished depending on the checkboxes. It just creates more bugs when playing around with the languages itself because the languages are a widespread feature in ProcessWire which are affecting other classes. With the new hook I am preventing that in some way since I have more control over what I am doing.
    public function init() { $this->addHookAfter('InputfieldForm::render', $this, 'renderForm'); } public function renderForm(HookEvent $event) { $id = $event->object->attr("id"); if($id != "ProcessPageEdit") return; $pageID = (int) $this->input->get->id; if(!$pageID) return; $page = $this->pages->get($pageID); $_out = ""; $index = ""; if($page->id){ foreach($this->languages as $key => $language) { if(!$page->languages_active->has($language)){ $_out .= "div[data-language='{$language->id}']{ display: none!important; }\n"; if($language->isDefault()){ $_out .= ".langTabs > ul li:first-child{ display: none!important; }\n"; } else { $_out .= "li[aria-controls$='__{$language->id}']{ display: none!important; }\n"; } } else { if(!$index) $index = $key; } } if($index) { $tabJSConfig = $this->wire('config')->js('LanguageTabs'); $tabJSConfig['activeTab'] = $index; $this->wire('config')->js('LanguageTabs', $tabJSConfig); } } if($_out) $_out = "<style>$_out</style>"; $event->return .= $_out; }  

    The above selection creates this inline CSS:
    <style> div[data-language='1029']{ display: none!important; } li[aria-controls$='__1029']{ display: none!important; } div[data-language='4286']{ display: none!important; } li[aria-controls$='__4286']{ display: none!important; } div[data-language='5842']{ display: none!important; } li[aria-controls$='__5842']{ display: none!important; } </style>
  2. Orkun's post in A Question to the showIf Option for Inputfields... was marked as the answer   
    Solved it by adding the $list_id to the fieldParam name attribute. After that I just have to do this:
    $field->showIf = "method_recipient=groupSegment, fieldParam_$list_id=$groupID";
  3. Orkun's post in Add Page Shortcut Menu was marked as the answer   
    This worked for me:
    I'm doing a "addHookBefore" inside the ProcessPageAdd::executeTemplate Method.
    public function init() { if(!$this->user->isSuperuser() && $this->user->hasRole("XXXXXXXX")) $this->addHookBefore('ProcessPageAdd::executeTemplate', $this, 'redirectParent'); } Inside the redirectParent Hook Method
    public function redirectParent(HookEvent $event){ //Get ID from URL $templateID = (int) $this->input->get->template_id; //Check if it's a Newsletter if($templateID == 66){ //Get the Parent Page specified by the choose_sender_2016 Pagefield in the user & newsletter Template $parent = $this->pages->get("template=newsletter-clinic, choose_sender_2016={$this->user->choose_sender_2016}"); //Check if a Parent was found if($parent->id){ //Skip the Parent Selection with a redirect $url = "./?parent_id=" . $parent->id; if($this->wire('input')->get('modal')) $url .= "&modal=1"; $this->wire('session')->redirect($url); } } }
  4. Orkun's post in Get Localized Month/Date from three different Languages on same template by looping through languages was marked as the answer   
    I've solve the problem by setting the setlocale(LC_ALL, 'xx_XX.utf8') in every case with the right locale code. 
    The endsolution looks like this:
    foreach ($languages->find("name!=en") as $language) { $user->language = $languages->get($language->name); switch ($language->name) { case 'default': setlocale(LC_ALL, 'fr_FR.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; case 'de': setlocale(LC_ALL, 'de_DE.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; case 'it': setlocale(LC_ALL, 'it_IT.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; } echo $date."<br />"; } I thought, that when I would change the user language on every loop, it would also change the LC_ALL but somehow it doesn't do that. So I set the setlocale manuallay on every loop.
    When you need other locale-codes here is a list of all languages(or probably the most of it):
    And also thank you to @LostKobrakai, he pointed me to the right direction!
  5. Orkun's post in Language Change for Options Field(Select Options Fieldtype) was marked as the answer   
    This Solution worked for me: https://processwire.com/talk/topic/9105-select-options-fieldtype-possible-to-output-all-available-options-in-template/
  6. Orkun's post in Set PHP-Selector for pagefield with predefined default value was marked as the answer   
    This should do the work:
    if(wire('user')->isSuperuser()){     return $pages->find("template=organiser"); } else{     return $pages->find("template=organiser, id=".wire('user')->select_organiser); }
  7. Orkun's post in Fredi can't render a page from a pagefield from a user? was marked as the answer   
    Solve the Problem: I had set the access of the organiser-template false. Only Superusers could access pages with this template. So the access to the organiser-template was denied for users with role company.
  • Create New...