Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Zeka

  1. Hi @taoguang

    Lest assume that you have this structure

    Books ( template: books )
    - Book ( template: book )
    - Book 1 ( template: book )

    Authors ( template: authors )
    - Author ( template: author) 
    - Author 1 ( template: author) 

    So to link author page to its books you have to create two page-reference fields: books and authors. 

    The 'books' fields should use 'book' template as the selector and 'authors' field should use 'author' template as the selector. 

    Then add 'books' field to 'author' template and 'authors' field to 'book' template'.

    Also, you can use this module https://modules.processwire.com/modules/connect-page-fields/ You can find why it would be helpful for your purpose by reading the description on its page.

    • Like 3
  2. @Sergio  Thanks, I have tried all from that thread, but it also doesn't work. $this->wire("user")->language->name always returns 'default', but in ready.php or ready modules method it works as expected, so it seems that user language is determined and set on ready stage here

    The issue that I'm trying to solve: I'm using Padloper and by accessing 'padloper/ajaxViewCart/' I can get the view of the cart for ajax requests. It works as expected for default language, but not for non-default languages. So, I was trying to find a way how to get current language, but now I assume that it's not going to help as on init stage there is no page object and I actually can't get non-default lang values of fields. Here the code which responsible for that.

    public function init() {
    	.....
    	$this->addHookBefore('ProcessPageView::execute', $this, 'runPadloper');
    	....
    }
    
     public function runPadloper($event) {
    
        $it = isset($_GET['it']) ? $_GET['it'] : "";
        if (substr($it, 0, 1) === '/') $it = ltrim($it, "/");
    
        // We only allow urls like /padloper/ and /d/ here
        if(strpos($it, "padloper/") !== false || strpos($it, "d/") !== false) {
          // Do nothing
        } else {
          return;
        }
    
        switch ($it) {
    
    	.....
    
          case 'padloper/ajaxViewCart/':
            echo $this->modules->get("PadRender")->viewCart();
            exit();
            break;

     

  3. @MSP01

    You can create endpoint (template and page)  where you can catch get parameters like ?unsubscribe=140530045 or ?disable=140530045 then do something like

    if($input->get->unsubscribe || $input->get->disable) {
    	$subscription = $pages->get($sanitizer->pageName($input->get->unsubscribe));
    	
    	if($subscription->id && $input->get->unsubscribe) {
    		$pages->trash($subscription);
    	} elseif ($subscription->id && $input->get->disable) {
    		... logic for disabling user subscription
    	}
    } 

     

    • Like 2
  4. From https://processwire.com/api/selectors/https://processwire.com/api/selectors/https://processwire.com/api/selectors/

    Quote

    The *= and ~= rely upon MySQL fulltext indexes, which only index words of at least a certain length (configurable, but typically 4 characters). They also don't index common English words called stopwords. So while it's preferable to use *= and ~= for their speed, if you aren't getting the results you need, you should consider using %= instead (if you can handle the speed hit).

    1

     

    • Like 4
    • Thanks 1
  5. Hi @DV-JF

    It's not possible to deactivate the default language in PW.

    You can create custom inputs (checkboxes) to enable/disable specific language for page and then in your template check whether this page is viewable for this language and if not throw 404. 

    In that way, you will rely on custom inputs for languages, so default language checkboxes should be checked for languages. You can use this hook for that

    $wire->addHookAfter('Pages::added', function($event) {
      $page = $event->arguments(0);
      foreach ($this->wire->languages as $lang) $page->set("status$lang", 1);
      $page->save();
    });

    One drawback that I'm thinking about is that in your find() methods you have also check if this page viewable for this language. 

    This is not tested but may work. 

    Also, take a look at this module, you may find it useful in some cases

     

    • Like 2
  6. @MilenKo

    There are two routes how you can achieve ML menus with MB.

    1. Create separate menu for every language and depending on user language pass different pages for menu render method.

    2. Enable additional language for the menu ( Settings tab -> Other active languages for this menu) I think that it is what you are looking for.

    • Like 1
×
×
  • Create New...