Jump to content

Matzn

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by Matzn

  1. Ok, then I understood your family restrictions setting. No, in none template set family restrictions. I've already checked everything - what I know. If the template is unused i can change the page to them, but not if used for other page. I despair...?
  2. No, "Don't allow pages to change their template" is not checked. I'm the superuser and the parent page is home. I'm not sure what do you mean with family restriction by parent page?
  3. Hi. I use a fresh multilanguage site. I only change default language to german. Now i can't chang the page template after use this template for one page, although multiple use is permitted. Some ideas?
  4. @tomaskostadinov and how do you access the fields by language? I found only a solution by suffix. Or there is another solution?
  5. Ok, it seems as if the fields are only translated for the Pageobject. Either you create a page and moves all fields there or you call up the fields of the modules include the suffix as follows: english: myField german: myField__1024 if ($user->language->name != "default") $lable = "__" . $user->language->id; $modules->get('Mymodule')->get("myField$lable");
  6. Hi @Zeka some fields from $page are switch in right language, but not the field from modul. It doesn't matter whether I call up the modul-field in the template or via hook.
  7. Hi. To manipulate the page output i use the hook Page::render. It works for html, php etc without touch the templatefiles. Example i build a modul called "Mymodul" and integrate some multilanguages fields: class MymodulConfig extends ModuleConfig public function getInputfields() { $inputfields = parent::getInputfields(); $ckeditorToolbar ='Format, Bold, Italic, -, RemoveFormat'; $f = $this->modules->get('InputfieldCKEditor'); $f->toolbar($ckeditorToolbar); $f->attr('name', 'myField'); $f->useLanguages = true; $inputfields->add($f); return $inputfields; } } and add it to all pages: public function ready() { if ($this->page->template != 'admin') { $this->addHookAfter('Page::render', $this, 'addSome'); } } public function addSome($event) { ob_start(); eval('?>'.'<?php echo $this->modules->get('Mymodule')->myField ;?>'. '<?php'); $add = ob_get_contents(); ob_end_clean(); $event->return = str_replace("</body>", $add . "</body>", $event->return); } What i'm missing are the variables for $languages and the switching of the multi languages fields from module. Does somebody has any idea why get only the default language field from modul?
  8. Hui, the solution is very easy: $matches = $pages->find("selector")->not("selector"); Example for trees: //all 1,5m no 11,5m $matches = $pages->find('title%=tree, title%="1,5 m")->not(title%="11,5 m"'); //all 11,5m no 1,5m $matches = $pages->find('title%=tree, title%="11,5 m")->not(title%="1,5 m"');
  9. Thanks all for yous ideas. I must had a tittle more explain my project. The page listing all trees und i use the height for a ajax filter function. I wan´t add a new field. It was more about the basic to the selectors. Hope external links ok. A example: https://gutschein-für.de/preisvergleich/layher-uni-komfort-fahrgeruest-universalgeruest-mit-treppenaufstieg/ @MoritzLost It would be good, but you dirt solution don´t work 'title%=" 1,5 m". All Whitspaces lost. @Robin S Yes, if add a additional word befor it works, but need only "1,5m"/"11,5 m"
  10. I have some page titles, eg.: green tree 1,5 m brown tree 1,5 m green tree 11,5 m brown tree 11,5 m yellow banana 0,5 m To find all 1,5 m trees is my selector ('title%=tree, title%="1,5 m"') , but results are also 11,5 m trees. My first idea was to exclude "11,5 m" ('title%=tree, title%="1,5 m", title!%="11,5 m"') But exclude 1,5 m for 11,5 m searching i get not results ('title%=tree, title%="11,5 m", title!%="1,5 m"') Yes, i have tested *=, ~=. What am i missing?
  11. Your function returns only category 3. To get all pages (categories) in you category tree you can $kategorien = $page->find(); //or $kategorien = $page->descendants(); After count your products for each category foreach ($kategorien as $kategorie){ $count = $pages->count("template=produkt, pro_kategorie={$kategorie->id}"); echo $count . " Produkte in Kategorie " . $kategorie->title; }
  12. Hi, use $pages->count https://processwire.com/api/ref/pages/count/ for each category like: $cnt = $pages->count('parent=yourCategory,id=yourProductId');
  13. Hi. I need the repeater id by a field inside the repeater via api. $repeater = $page->my_repeater; foreach ($repeater as $row) { if ($row->id == "repeater->myField->inside_the_repeater_row"){ ..someting } } For a selected field i need it, but a chikld from a other selected field. Maybe you have a better idea? $wire->addHookAfter('InputfieldPage::getSelectablePages', function ($event) { if ($event->object->hasField == 'productOptionValue') { $page = $event->arguments('page'); $options = $page->product_options; foreach ($options as $option) { if ($option->id == "285110") { $selector = 'parent=' . $option->product_option_key; } } $event->return = $event->pages->find($selector); } });
  14. Maybe, you must switch the language by $language->get('de'); and after $pages->find https://processwire.com/docs/multi-language-support/multi-language-fields/#getting-and-setting
  15. Ok, you are right @Robin S. I think, now i understand you. ?‍♂️ Your idea to use a field for the parent-child relationship works great: I add a empty repeaterfield to template. In ready.php i add to a edit button (each children page) include pagination. It looks like it´s a repeater field items (old page situation). All happy. $this->addHookAfter('Inputfield::render', function (HookEvent $event) { $field = $event->object; $form = wire('modules')->get("InputfieldForm"); //get edit page $page_id = $this->input->get('id'); $page = $this->pages->get($page_id); //add child pages to empty repeater - items not moveable, deletable or to clone if ($field->name === 'products') { $childPages = $page->children('limit=15'); $pagination = $childPages->renderPager(['getVars' => array("id" => $page_id)]); foreach ($childPages as $childPage) { //build the fake-repeater header $wrap = $this->wire('modules')->get('InputfieldFieldset'); $wrap->addClass('InputfieldRepeaterItem InputfieldStateCollapsed InputfieldRepeaterMinItem InputfieldNoFocus'); $wrap->name = "repeater_item_{$childPage->id}"; $wrap->label = $childPage->index + 1 . ': ' . $childPage->product_title . ' Art.: ' . $childPage->title; //if all fields are filled out mark the header $isFilledOut = ($childPage->product_keyword && $childPage->product_type); ($isFilledOut ? $wrap->addClass("text-black", "headerClass") : ""); //add the edit button for the child page (class pw-modal for modal edit) $submit = wire('modules')->get("InputfieldButton"); $submit->attr("value", "Produkt Details bearbeiten"); $submit->attr('data-href', wire('config')->urls->admin . "page/edit/?id=" . $childPage->id); $submit->addClass('pw-modal uk-margin-bottom uk-margin-left'); $wrap->add($submit); $form->add($wrap); } $field_style = '<style>.text-black{color:black !important;}.InputfieldRepeaterItemControls{display:none !important;}</style>'; $event->return = $form->render(); $event->return .= $field_style; $event->return .= $pagination; } });
  16. Hi @Robin S , that was a misunderstanding. I understood i should put the data in a child's page, which i had already done and was shown in the first screenshot. But you mean the page lister for parent child relationship. Sorry for that. Why i want to solve this with repeaters is because it offers a better overview and is easier to operate (project requirement). Parents' page is the brand (there are many) next child is the repeater and all last children are the product data. However, the product data must be edited manually (fill in 2 additional fields). Once the product has been processed, the repeater header is marked in color. That's my idea for the solution to this project. I'll take a look at that.
  17. Thanks @Pixrael I think the best solution is from @louisstephens for buying the profields plugin: https://processwire.com/blog/posts/fieldtype-pagination/#example-profields-table. I looking now 1 hour for this issue and this plugin coast only 129,-€ Thanks all. closed
  18. Thanks for your replies. Your are right for the closed field, but not for loading rows. That i have done. Look at the screenshot. Only title, product_id and the button to child page. Maybe the solution would be to limit the the pages befor output. For example in ready.php like this: $this->addHookAfter('Inputfield::render', function (HookEvent $event) { $Inputfield = $event->object; if ($Inputfield->name == 'products') { $limitedPages = $this->pages->find('limit=5,id=' . $Inputfield->hasPage->children); $pagination = $limitedPages->renderPager(['getVars' => array("id" => $this->input->get('id'))]); $event->return = $Inputfield; $event->return .= $pagination; } }); Pagination render and a get a limited page object, but the page object expect something that i don´t know. Some ideas?
  19. I have a page with only one repeater field. But there are many rows(1000 or more). You already guessed it, this page loading very slow if i want editing. Can i add pagination for repeater rows or you have some idea for this slow down issue?
  20. Ok, now i understand that a selector finds only a page not a separated field. For my solution i must iterate the arrays or i using a own db query.
  21. Yea, my first post. I used processwire a time, but always all questions a found in this great forum. Thanks to all members. I know, i finding a page by selector. Like this: $pages->find('template=repeater_products, check_access=0, product_keyword=' . $page->title); But, how i find all values by a field name? For example, the code below give 3 results, now i want all values from a field as array. E.g. product_option_key from my screenshot like this: [0] => Speicher [1] => Farbe At time i use the php way, like this: $productOverviewList = $pages->find('template=repeater_products, check_access=0, product_keyword=' . $page->title); $productOptionList = []; foreach ($productOverviewList as $item) { foreach ($item->product_options as $key) { if (array_key_exists($key->product_option_key->title, $productOptionList)) { $str = $productOptionList[$key->product_option_key->title] . ","; $str .= $key->product_option_value; $productOptionList[$key->product_option_key->title] = $str; } else { $productOptionList[$key->product_option_key->title] = $key->product_option_value; } } } Maybe you have a better solution for me?
×
×
  • Create New...