Jump to content

Orkun

Members
  • Posts

    295
  • Joined

  • Last visited

Everything posted by Orkun

  1. I am using this index field because there are many many fields. And with many many fields I also mean pagetables, repeaters, lot of pagefields and options fields. Most of them is for the controlled output which makes it harder to define which fields I should search inside my search.php. So I decided to go this way, since It will search anything that is visible/rendered on a page and this erase the step to define which fields I should intelligently include in my search so that it would return good search results. Because of this I also abandoned the idea to change the actual method with the one where I loop through all fields and prepare them, since every template has a lot of other complexity and purpose. It just would take to much time to consider all this factors within the search query since I would need to update the code every time a new field or new complexity are added to the template output. For the urlSegments I have thinked of giving some arguments to the render method like this: protected function hookIndexingBefore( HookEvent $event ) { $page = $event->arguments("page"); if(!$page->template->hasField("index")) return; // no index field in this page/template if($page->isNew() || $page->isTrash()) return; $language = $this->wire("user")->language; // save user lang $page->index = ''; if($page->template->name == "jobs"){ //the page is a detail page so render the partial file with some options $filepath = "templates/partials/jobs-detail.php"; $options = array("pagename" => $page->name); }else{ // render the page with its own template $filepath = ""; } foreach($this->wire("languages") as $lang) { $this->wire("user")->language = $lang; // change user lang wire('pages')->setOutputFormatting(true); $content = $page->render($filepath, $options); wire('pages')->setOutputFormatting(false); if($content) $content = $this->parseContent($content); $page->index .= $content; } $this->wire("user")->language = $language; // restore user language } And the inside the partial file at the moment I have this: <?php if($urlsegment){ $urlpage = $pages->get("name=$urlsegment"); } ?> markup .... I need to add this so it also works with the hooks above: <?php // check if detail page is accessd and rendered in normal way if($urlsegment){ $urlpage = $pages->get("name=$urlsegment"); } // page is render via page->render() method from the saveReady Hook if($options['pagename']){ $urlpage = $pages->get("name=".$options['pagename']); } ?> markup... Don't know if this will work have to try this. Greetings Orkun
  2. Thanks for your Input @Robin S! I think I will go with the last option since it would solve another problem I have ;D. Greetings Orkun
  3. Thanks for your clarification @Robin S I'm asking because I am using this module right now for text and textarea fields for my sitewide search. At the moment I am using two methods to build my search. The first method is a hook inside saveReady which renders the actual page and cleans it's content from html and writes it inside a textarea field called "index" which I had created and assigend to the corresponding template/page. This works very good and in my search.php my selector looks like this: $siteSelector = "index*=$q, numChildren=0"; But there is a problem with this approach. Many of the detail pages on my site are using urlSegments to render it's content. And I don't know how I should render the views for the detail pages since they are not physically pages rather rendered dynamically through urlSegments. So I come up with the FieldtypeCache which collects the content of the specified fields and make it searchable by 1 field. Perhaps I should change the Hook and should not render the views rather prepare the content of every field in the page and save it inside the index field. This is probably also more consistent and easier to maintain then to have two endpoints I need to take care off.
  4. I think it has somehow something to do with the $page->render(). Because when I do this: $content = <!--### start-indexing-area ###-->This is a sample Text<!--### end-indexing-area ###-->; The Internal Server Error doesn't appear anymore. But when I save the $page->render() as $content I get the internal server error... It has also no effect when I do $page->render and skip the parseContent section, It still appears an internal server error.
  5. Anything new on that topic @BitPoet? I really need this since it is one of the top priorities of my customer. I understand why he wants this, since it is irritating when you go on a page and there is no content for the actual language. The default fallback at the moment is french, but some pages doesn't have french content and the customer doesn't want to fillout the "Default/Fallback Language Tab" since it is a "step more" he needs to take care of. I thought this through and I am thinking of going another way to avoid "empty frontend pages". How about filling the default language tab with the content of the language that you have specified under the "absender". I think this would work good for text and textarea fields. The disadvantages of this approach is, that I need to take care of the hooking code since fields and templates could be changed or new ones could be added. The hooking code could also be bloated, since there are many templates and fields. In the end it means just more maintenance then the first approach, but more control over what I am doing. How do you think of it guys?
  6. Hi Guys Do you perhaps know, if this fieldtype is also capable of searching through all repeater/pagetable/page fields when I am referencing one of these fieldtypes inside the field options of a cache field?
  7. Thanks for your Input @adrian and @Robin S I now changed the addHookAfter to addHookBefore. The indexing is still working. But the problem(internal server error) with saving from api when the hook is active is still consistent. The parseContent function contains some preg_replaces and strip_tags to clean out the html and define the "indexing area" so that the nav and footer content isn't indexed all the time. parseContent() protected function parseContent($content){ $startStr = "<!--### start-indexing-area ###-->"; $endStr = "<!--### end-indexing-area ###-->"; preg_match_all('/'.$startStr.'(.*)'.$endStr.'/siU', $content, $matches); $newContent = preg_replace("/<div class='breadcrumb.*'>.*<\/div>/siU", '', $matches[1][0]); $newContent = str_replace('<', ' <', $newContent); $newContent = strip_tags($newContent); $newContent = preg_replace("/\s\s+/", " ", $newContent); return $newContent; } It's really weird that it is causing a 500 internal server error when saving from api but it isn't causing a 500 internal server error when saving from backend, when the hookIndexingBefore is active.
  8. Hi Guys This hook works fine. $this->addHookAfter('Pages::saveReady', $this, 'hookIndexingBefore'); protected function hookIndexingBefore( HookEvent $event ) { $page = $event->arguments("page"); if(!$page->template->hasField("index")) return; // no index field in this page/template if($page->isNew() || $page->isTrash() || $page->indexSaveFlag) return; $language = $this->wire("user")->language; // save user lang $page->index = ''; foreach($this->wire("languages") as $lang) { $this->wire("user")->language = $lang; // change user lang wire('pages')->setOutputFormatting(true); $content = $page->render(); // render page and get the content wire('pages')->setOutputFormatting(false); if($content) $content = $this->parseContent($content); //remove html, new lines etc... $page->index .= $content; } $page->indexSaveFlag = true; // in case it get's saved again (not case with Pages::saveReady) $this->wire("user")->language = $language; // restore user language } But when I try to save a page per api I get an Internal Server Error 500. When I replace "$page->render();" with "" inside the hook, it doesn't cause a internal server error anymore. $page->save(); //causes internal server error now
  9. This doesn't work so well somehow. Now I am doing the hook when the $currPage Template is "overview-content-page or fetch-content-page". This both templates are used to output News/Babies/Events/Specialities/Doctors per Url Segments etc... It Inherits the new language but It looks like, that it always outputs content in the new inherited language even when the field has content in other languages than the inherited language (Should that supposed to be like that?). My current Code Snippet looks like this: public function hookLangInherit(HookEvent $event){ $mlObj = $event->object; // LanguagesPageFieldValue object $currPage = $this->wire('page'); if($currPage->is("template=overview-content-page|fetch-content-page")) { //check if detail page is accessed if($this->input->urlSegment1){ // The overview-content and fetch-content pages are living under a specific rootParent which has assigned a specific "absender" $absender = $currPage->rootParent->choose_sender_2016; // Get The new language by a custom pagefield(single) from the "absender" $sprache = $absender->inheritLanguages; $newLangValue = $mlObj->getLanguageValue($sprache); if($newLangValue == ""){ // Fallback to default language when value is empty in the inherited language $newLangValue = $mlObj->getLanguageValue(1010); } // Get the new values in that language $event->return = $newLangValue; } } } EDIT: I added a little fallback to the code snippet above. When the Language Value is empty in the new inherited language it uses the default language again as new inherited language. Greetings Orkun
  10. Thanks @BitPoet This works when I access a doctor(template/page) directly. What when I am fetching the doctor output and putting it out on a overview-page where you can access the details of a doctor per url segment?
  11. I'm on my mac. I've tested it on chrome, firefox and safari. The bug is happening in all 3 browsers. I had installed the Module with "Add module from Upload". It created a new folder and changed the old folder to hidden. After that I have updated the media manager and removed the mmplugins from all fields and also from the inputfieldckeditor plugin folder. EDIT: It's weird. Sometimes it works and sometimes not? It doesn't work with the images which are very big/long in height (1000px x 2000px). And this behavior also happens only then when the long image was selected first.
  12. Possibly I explained it not good enough sry for that. Yeah I understand/know that the image jumps to the top when scrolling so that I can see the image always. But when I go up again the image still has the fixed class. You can see in my previous post, that the image overlaps the search menu...
  13. @kongondo Found a possible CSS/JS Bug I think in the new Version. When I scrolling the selected image jumps to the top and stays there.
  14. @kongondo How do I have to update the Media Manager? Just overwrite the whole folder with the new one? It shouldn't affect any media manager fields that are assigned to templates or other related stuff with the media manager? Do I have to pay attention to some steps before replacing the old module folder with the new one? I just want to be careful and I dont want to break anything. Greetings Orkun
  15. Hi Guys I have 3 files. templates/signup-form-formbuilder.php partials/sharedtemplates/signup-form-formbuilder.php _main.php I outsourced the code from templates/signup-form-formbuilder.php to partials/sharedtemplates/signup-form-formbuilder.php. In the templates/signup-form-formbuilder.php file I am doing this: $out .= wireRenderFile('partials/sharedtemplates/signup-form-formbuilder.php'); It works. The content of the file in the sharedtemplates will be rendered inside the original template file and the outputed in the _main.php with $out variable. But the problem now is, that I have this code inside of the _main.php in the head section to render the formbuilder styles: if(isset($formFormBuilder)){ echo $formFormBuilder->styles; echo $formFormBuilder->scripts; } The $formFormBuilder was defined before in the original template file (templates/signup-form-formbuilder.php) . But now it is defined in the file inside shardetemplates folder (partials/sharedtemplates/signup-form-formbuilder.php). Since wireRenderFile just outputs the content it can't recognize the $formFormbuilder inside of the (partials/sharedtemplates/signup-form-formbuilder.php) file since the whole file content is outputted already in the $out var. It worked before, because the _main.php file is always append to the templates. I had to outsource the code of the original template, because I need to output the form also on other templates. How can I make the $formFormBuilder available again for the _main.php?
  16. Hi @Robin S I didn't noticed this issue. But thanks for solving it. I will try it out later, have to do some other stuff now. Greetings Orkun
  17. Hi @kongondo Could you say a period when you release the version 7 of the media manager? My Customer urges me, that he wants to start uploading images. I think it shouldn't be a problem to update the module when there are uploaded images? Greetings Orkun
  18. Yeah you're right. Because of this I had done this: $items = $pages->find("sort=-created, template={$page->choosetemplate->title}, choose_sender_2016_multi|parent.choose_sender_2016={$page->rootParent->choose_sender_2016}, limit=$page->number"); if($items->getTotal() >= 100){ $items = $items->setTotal(100); } $paginationMarkup = $items->renderPager(array( 'nextItemLabel' => '<i class="fa fa-angle-right"></i>', 'previousItemLabel' => '<i class="fa fa-angle-left"></i>', )); But now I see that your solution is much cleaner :), Thanks @LostKobrakai
  19. Thanks for your input guys, @Robin S & @Martijn Geerts Lets clarify a few points what I have tried already. # Method 1 // The customer wants to set the items per page. Lets say it's 10 for the moment $limit = $page->number; // Remember: There are only 12 Event Pages at the moment $items = $pages->find("sort=-created, template={$page->choosetemplate->title}, choose_sender_2016_multi|parent.choose_sender_2016={$page->rootParent->choose_sender_2016}, limit=$limit")->setTotal(100); // Output Markup $paginationMarkup = $items->renderPager(array( 'nextItemLabel' => '<i class="fa fa-angle-right"></i>', 'previousItemLabel' => '<i class="fa fa-angle-left"></i>', )); This method works halfway. It only works when the setTotal Number is divisible with the limit. But another thing that I noticed is, that now it outputs 10 pagination Links. The first pagination page renders 10 events, the second page renders 2 events and all the other pagination pages are empty. (visualized in the image) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # Method 2 (Martijns Method) // Remember: There are only 12 Event Pages at the moment $items = $pages->find("sort=-created, template={$page->choosetemplate->title}, choose_sender_2016_multi|parent.choose_sender_2016={$page->rootParent->choose_sender_2016}, limit=100"); // Remember $limit is 10 at the moment (set by user in the backend by an integer field) $items->setTotal($items->count())->setLimit($limit)->setStart(0); $pager = $modules->get('MarkupPagerNav'); $paginationMarkup = $pager->render($items, array( 'nextItemLabel' => '<i class="fa fa-angle-right"></i>', 'previousItemLabel' => '<i class="fa fa-angle-left"></i>', )); This example doesn't really work. It outputs all 12 events on the first pagination page and on the second page the pager disappears and no events are displayed. Greetings Orkun
  20. Thanks @Robin S Now the limit per page is working, but the total is ignored - still getting all records from the database. [Edit] it seems to be working. But only if the number in the total is dividable by the limit without a rest. So limit = 3 and setTotal = 10 doesn't work, but limit = 3 and setTotal = 9 works
  21. Thanks both of you. But now the pager doesn't work at all, it just outputs all events. My code looks like this: $items = $pages->find("sort=-created, template={$page->choosetemplate->title}, choose_sender_2016_multi|parent.choose_sender_2016={$page->rootParent->choose_sender_2016}")->setTotal(10)->setLimit(5); $pager = $this->modules->get('MarkupPagerNav'); $paginationMarkup = $pager->render($items);
  22. Thanks @flydev - but this doesn't answer my question. I only need 100 entries from the database, even though there might be more. So let's say, I have 200 entries in the DB, I only want the first 100 and THEN paginate these 100 entries. When I use limit/start, though, I always get all entries with the find-method.
  23. Hi Guys This is possibly a stupid question but I can't get it to work. How can I limit the max number of pages I get and paginate them afterwards with a different limit(per pagination page)? Lets say I have a total of 1000 Events. I want to output 100 Events (10 Events per pagination page). // outputs 10 events per page but returns all 1000 events - how pagination works default $items = $pages->find("template=event, limit=10"); // should output 10 events per page but should only use the 100 latest events for output - doesn't work // Try 1 $items = $pages->find("template=event, limit=100")->find("limit=10"); // Try 2 $items = $pages->find("template=event, limit=10, getTotal=100"); // output pager echo $items->renderPager(); Can someone clarify that to me? Greetings Orkun
  24. Hi @kongondo I wanted to ask if its possible to have this list view change for the media manager fields also for the media manager process page? My Customer wants to see the filename of every image/file without clicking on it. And have you thought about integrating this fixed filters(like Lister Pro) for the media manager? My customer needs them since it's a big company with many workers, and it would be just time consuming to build the filters every time when the user is logged in. Greetings Orkun
×
×
  • Create New...