Jump to content

joe_ma

Members
  • Posts

    182
  • Joined

  • Last visited

Everything posted by joe_ma

  1. Hi I have the following code in search.php (modified from the original one): <?php // look for a GET variable named 'q' and sanitize it $q = $sanitizer->text($input->get->q); // did $q have anything in it? if($q) { $input->whitelist('q', $q); $q = $sanitizer->selectorValue($q); // Search the given fields for our query text. // Limit the results to 50 pages. $selector = "headline|title|body|sidebar|untertitel|mitwirkende|moderator~=$q, limit=50, template=event|basic-page|kontakt"; if($user->isLoggedin()) $selector .= ", has_parent!=2"; // Find pages that match the selector $matches = $pages->find($selector); // did we find any matches? if($matches->count) { // yes we did: output a headline indicating how many were found. // note how we handle singular vs. plural for multi-language, with the _n() function $content = "<h2>$matches->count Seite(n) gefunden, die Ihren Suchkriterien entspricht/entsprechen:</h2>"; // create dt-list with results $content .= "<dl>"; foreach ($matches as $m){ $content .= "<dt><a href='{$m->url}?searched={$q}'>$m->title</a></dt>"; if(strlen($m->body) > 250) { //Limit text to 250 signs and whole words $m->body = substr($m->body,0,250).'…'; $string_ende = strrchr($m->body, ' '); $m->body = str_replace($string_ende," …", $m->body); // } $content .= "<dd><span><a href='{$m->url}?searched={$q}'>URL: $m->url</a></span><br>" . strip_tags($m->body) . "</dd>"; } $content .= "</dl>"; } else { // we didn't find any $content = "<h2>" . __('Sorry, no results were found.') . "</h2>"; } } else { // no search terms provided $content = "<h2>" . __('Please enter a search term in the search box (upper right corner)') . "</h2>"; } Now everything works fine with any search terms, except numbers. When I search for numbers, I get the following error: Thanks for your help.
  2. So I finally found the culprit: jqery TabeSorter. Without TableSorter, the table is sorted correctly. Thanks a lot for your help.
  3. OK, I tested it with the FieldtypeTime. But nothing changed.
  4. Ah, thank you. But anyway: if I change $events = $pages->find("template=event_date, include=hidden, sort=datum, sort=zeit") to $events = $pages->find("template=event_date, include=hidden, sort=datum") Sorting is not correct either. And since I have stored the correct date also with the "zeit" field, couldn't I sort it like this $events = $pages->find("template=event_date, include=hidden, sort=zeit") But all of these solutions dont sort correctly.
  5. Sorry for being stupid: I cannot find a fieldtype Time …
  6. Hello Same problem here. I have got this code in a template building a table: $events = $pages->find("template=event_date, include=hidden, sort=datum, sort=zeit"); //get all the events to display in the table foreach ($events as $e) { $datum = date("d.m.", $e->getUnformatted("datum")); // display the date as e.g. 25.12. $wota = date("w", $e->getUnformatted("datum")); // for weekdays $tage = array("So, ","Mo, ","Di, ","Mi, ","Do, ","Fr, ","Sa, "); $tag = $tage[$wota]; $content .= '<tr><td class="tag">{$tag}</td><td class="datum">{$datum}</td><td class="zeit">{$e->zeit}</td><td class="vorstellung"><a href='{$e->parent->url}'>{$e->parent->Programmtitel}</a>'; the fields "datum" and "zeit" are datetime fields that are set to output "25.10.2016" and "22:00" respectively. Both of them have autojoin checked. The output of the code is as intended: Fr, 06.11. 18:30 "Title-of-the-event" BUT: Sorting is not correct. PW 2.8.22
  7. Thanks a lot! Sounds promising. I'll give that a try.
  8. Hello I got a front page design consisting of a dozen of div elements. Some of them are containers for teasers, some are just decorations or ads or whatever. The problem I have is that the teaser blocks don't succeed each other: - div 1 (title) - div 2 (teaser) - div3 (ads) - div 4 (teaser) - div 5 (teaser) - div 6 (decoration) … You get the idea. The information for the teasers come from a page array ($teasers = $pages->find('selector')), no problem with that. But how can I scatter these to the teaser divs? I cannot use foreach to build divs that don's succeed each other, can I? Any ideas on how to achieve this are welcome.
  9. Thank you very much, Soma. This does the trick.
  10. I have some kind of database in processwire that contains a whole lot of pages with addresses. These addresses are output in a table by a template that gets all the relevant information from these pages. To obfuscate the email addresses coming out of the database I use this module. Something seems to go wrong though, because the part in the <a> tag is not obfuscated, only the link part. This is what the source code of the page looks like: <a href='mailto:blb.op.biel-bienne@erz.be.ch' class='link_mail'><span style="unicode-bidi:bidi-override; direction: rtl;" class="email-obfuscator-unreverse">hc.eb.zre@enneib-leib.po.blb</span></a> And this is the line from the template, that outputs the email address: if($l->adr_email) $out .= "<a href='mailto:$l->adr_email' class='link_mail'>$l->adr_email</a> <br>"; The module is configured so that the javascript is being inserted before the </body> tag.
  11. Yes, stupid me. It came just to my mind in this second. Shame on me!
  12. Wow! Thank you very much for this concise answer. My search.php now looks like this: <?php // look for a GET variable named 'q' and sanitize it $q = $sanitizer->text($input->get->q); // did $q have anything in it? if($q) { $input->whitelist('q', $q); $q = $sanitizer->selectorValue($q); // Search the title and body fields for our query text. $selector = "title|body~=$q"; // First we find any matching address pages (category field = adr_rubrik) $addresses = $pages->find("template=adress_daten, title|adr_beschreibung~=$q"); $categories = new PageArray(); foreach($addresses as $address) { // And add their categories to a PageArray $categories->add($address->adr_rubrik); } $categories = $categories->unique(); // Strip out any duplicates if($categories->count) { // Now we use OR-groups to say either the body must contain the search term // or the page must have the same category as one of the matching addresses $selector = "($selector), (adr_rubrik=$categories)"; } // Search the website pages, but not address pages because we already dealt with them // If there is the potential of a lot of matches you should apply a pagination limit $matches = $pages->find("$selector, template!=adress_daten, limit=20"); if($user->isLoggedin()) $selector .= ", has_parent!=2"; $cnt = $matches->count; // did we find any matches? if($cnt) { // yes we did: output a headline indicating how many were found. $content = "<h2>" . sprintf(_n('Found %d page', 'Found %d pages', $cnt), $cnt) . "</h2>"; // create dt-list with results $content .= "<dl>"; foreach ($matches as $m){ $content .= "<dt><a href='$m->url'>$m->title</a></dt>"; if(strlen($m->body) > 250) { // limit to 150 signs $m->body = substr($m->body,0,250).'…'; $string_ende = strrchr($m->body, ' '); $m->body = str_replace($string_ende," …", $m->body); } $content .= "<dd><span><a href='$m->url'>URL: $m->url</a></span><br>" . strip_tags($m->body) . "</dd>"; } $content .= "</dl>"; } else { // we didn't find any content = "<h2>" . __('Sorry, no results were found.') . "</h2>"; } } else { // no search terms provided $content = "<h2>" . __('Please enter a search term in the search box (upper right corner)') . "</h2>"; } This works like a charm, thanks to Robin's help. Only thing: pagination doesn't seem to work. The limit in $matches limits the results themselves, not the display of the results. When I set the limit to e.g. 5, even the title says «Found 5 pages», even when there are more results than this.
  13. Nearly there, but not quite … So my search code looks like this: // Find pages that match the selector $matches = $pages->find($selector); $cnt = $matches->count; // did we find any matches? if($cnt) { // yes we did: output a headline indicating how many were found. // note how we handle singular vs. plural for multi-language, with the _n() function $content = "<h2>" . sprintf(_n('Found %d page', 'Found %d pages', $cnt), $cnt) . "</h2>"; // create dt-list with results $content .= "<dl>"; foreach ($matches as $m){ if ($m->parent->id = 1293) { // Page is an address and has no template to be displayd $rubriken = new PageArray(); foreach ($m as $adr){ $rubriken->add($adr->adr_rubrik); // add the categories from the pagefield (asm select) on the address page } $rubriken = $rubriken->unique; $results = $pages->find("template=basic-page, adr_rubrik=$rubriken"); // find the information pages with template basic-page that have the same categories as the address page foreach ($results as $r){ $content .= "<dt><a href='$r->url'>$r->title</a><br><span>URL: $r->url</span></dt>"; if(strlen($r->body) > 250) { // Limit displayed text to 150 signs $r->body = substr($r->body,0,250).'…'; $string_ende = strrchr($r->body, ' '); $r->body = str_replace($string_ende," …", $r->body); } $content .= "<dd>" . strip_tags($r->body) . "</dd>"; } } else { $content .= "<dt><a href='$m->url'>$m->title</a><br><span>URL: $m->url</span></dt>"; if(strlen($m->body) > 250) { // limit displayed text to 150 signs $m->body = substr($m->body,0,250).'…'; $string_ende = strrchr($m->body, ' '); $m->body = str_replace($string_ende," …", $m->body); } $content .= "<dd>" . strip_tags($m->body) . "</dd>"; } } $content .= "</dl>"; It seems like this is producing some kind of loop: the results keep repeating themselves. But I can't find out, where I made a mistake. Nice idea. But I haven't got a clue on how to do this. The filter is setup by the dataTable javascript.
  14. Thanks Robin for showing me the way to proceed. I'll give this a try. Thanks, I like it too.
  15. Thanks a lot for both of your answers. Yes, I think I didn't make myself very clear here. So, let me try it again: The website in question gives all sorts of information for people who deal with migration. I.e. administration people, employers and migrants themselves. Have a look for yourselves. There is also a data base with somewhat over 600 addresses. Each of them is a page, but doesn't have a template to be displayed. Both the information pages and the address pages have an asm select field for category. On the information pages these addresses are displayed according to their categories in a table. See this example: At the bottom of this page you find the addresses for the category "wohnen". What I'd like to achieve is, that (staying with the example above) when someone searches for "Ombudsstelle" (second row of the address table), the search results in the url of the information page rather than the address page of the "Ombudsstelle".
  16. Hi On a new site I use pw as a data base for addresses (located in the admin section of the page tree). On the pages these addresses are displayed in a table according to certain selectors. How can I include the content of these tables in the search results, in a way that the resulting links don't go to the data base but to the page, where the address is listed? Like this: Page about old age lists all addresses that have anything to do with old age like: - social insurance - rest home 1 - rest home 2 You get the idea. Now I'd like the search to "see" that "rest home 1" exists in the data base, but links to the page about old age. With the default settings of the search template, search results don't list information from the data base. I.e. if I search for "rest home 1", nothing is found. Thanks for help.
  17. The module could not be removed. So I deleted the row in the "modules" table, and also the files from the "site->modules" folder and the "aiom" folder from "site->assets". No I get this error, when I call the frontend: But there is nothing in the pw log, nor in the servers log. I can login in the backend. When logged in, I can view the site. Edit: I just became aware that it could have been because of the site cache. I now safed the home page again and now the frontend works again.
  18. I couldn't get the AIOM Module running and received error warnings. Now I came across the warning on the Modules page about not using it until the problems are solved. So I tried to uninstall the module, but with no success. I got this error: So I cannot uninstall the module. Is there a way to uninstall it manually?
  19. Yessss!! Thanks a lot to all of you. With the page field set to a single page, my OP code works fine. Exactly.
  20. Oh, but it seems so. $pages->get($s->color) doesn't work. Thanks anyway. @Kogondo: I'll have a look into pageTables; haven't used them so far.
  21. Yes, exactly. So, I really don't understand, why $s->color->title doesn't work. I found a solution, that does work now. $slogan = $page->get("banner"); foreach ($slogan as $s){ $farbe = $pages->get("id=$s->color"); echo "<div class='" . $farbe->title . "'>"; echo "<p>" . $s->keyword . "</p></div>"; }
  22. Hello I have a repeater ("banner") with two fields, one a text field ("keyword"), the other one is a page reference field ("color"). How can I get the title of the page this field is referencing? I have tried this $slogan = $page->get("banner"); foreach ($slogan as $s){ echo "<div class='" . $s->color . "'>"; echo "<p>" . $s->keyword . "</p></div>"; } This way I get the ID of the "color" page selected. As I need the title of this page, I tried echo "<div class='" . $s->color->title . "'>"; But then the output is empty. How do I get the title?
  23. Thanks a lot, justb3a. It seems I found out about that in the minute you posted your answer.
×
×
  • Create New...