Jump to content

Search the Community

Showing results for tags 'pagearray'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. I'm trying to sort a PageArray by $page->name and because there are digits in the name I need to use a natural sort (like php's natsort()). I've gone through the process outlined in https://processwire.com/talk/topic/3392-emulate-natsort/ but I must be missing something because I can't get it to work at all. I then tried a different way and created an array of the page names, used natsort and implode to give me a correctly sorted string to use in a selector. I then do $output = $pages->find("name=$selector_text"); and the correct pages are returned but they're not in the same order as in my selector string. I've only found a couple mentions of natural sorting on the forums so I must be missing something simple but I just can't put my finger on it.
  2. Hi Guys, So I have a template lots of articles . Approximately 23559 pages . I have a field article_id in say example template which is of type of PageArray to the articles template. Now when you try to load that particular template ( example ) PW is becoming slow.... And yes another server we have around 293363 pages and this can grow. So what is the best way to get much speed, or say the PageArray not to load all the stuffs for this is mainly used from an admin point of view. Any suggestions is welcome. Thanks
  3. Hi all, i have some problems when trying to add more pages with asmSelect. I have a field called "categorie" that contains an array of pages ( imagine the behavior of categories ). If i try to add one page from that field all works fine, if i try to add more than one page i get this error: I found that "1007" is the id of the default language. Maybe could be useful for reproduce this error. The field config is like this: There is something that i am missing ?
  4. Hey there. The pagination for my search isn’t working. I guess it has something to do with the merging of PageArrays beforehand. Take a look at the (simplified) search.php: $out = ""; if ( $q = $sanitizer->selectorValue( $input->get->q ) ) { $input->whitelist( "q", $q ); $pa = new PageArray(); $value = $pages->find( "title%=$q" ); $pa->import( $pages->find( "template=abc, …|…|…=$value" ) ); $pa->import( $pages->find( "template=abc, title%=$q" ) ); $result = $pa->find( "start=0, limit=4" ); $pagination = $result->renderPager(); $count = count( $pa ); if( $count ) { $out .= "<h2>Search results found</h2>"; $out .= "<ul>"; foreach( $result as $r ) { $out .= "<li>{$r->title}</li>"; } $out .= "</ul>"; $out .= $pagination; } else { $out .= "<h2>Sorry, no results were found</h2>"; } } else { $out .= "<h2>Please enter a search term in the search box</h2>"; } include("./head.inc"); echo $out; include("./foot.inc"); Pagination names are activated for the search template and the output of the pagination list is correct. When I go to "page2", "page3", etc. the result is always the very first 4 matches. Any help is appreciated, thanks! p.s.: I have to do the merging because one time I search for page references to a page (the "…" in the code) and one time for the title of a page with the template "abc". (offtopic: if you know a better solution to this just let me know)
  5. I've created sections of my page hierarchy to track different attributes, which I then use to populate a Page(Multiple) selector. They aren't displayed on the site; they're used as a kind of categorization method. I use the PageArray selector in many of my repeating fields. Then in the template code I ask for all the items in a particular branch of the hierarchy along with every instance of a repeating field that has been associated with that page via the PageArray selector. It looks like this: <?php if (trim($page->person)) { $cluepeople = $pages->get( "id=1344" ); $peopletypes = $pages->find( "parent=1582, include=hidden, sort=sort" ); foreach ( $peopletypes as $peopletype ) { echo "<h3>" . $peopletype->title . "</h3>"; $peopletypeid = $peopletype->id; settype($peopletypeid, "string"); foreach ( $cluepeople->person as $thisperson ) { $peopleselectorvalue = $thisperson->people_selector; settype($peopleselectorvalue, "string"); if ( $peopletypeid == $peopleselectorvalue ) { echo $thisperson->title; } } } } ?> I'd love a code review to know if this is a clumsy way of doing this and if there is an easier way (there usually is w/PW). Thanks, Jenn
  6. Hi, I'm just getting started with ProcessWire and am attempting to make the conversion from ExpressionEngine. My PHP skills are a little rusty, so please bear with me... So I'm trying to make a simple "Related Entries" field. I went with a Pages field type and am accessing the values through the PageArray/WireArray method. Before I get too deep into this, I was wondering if someone could look at this and tell me if I'm going about this in the right way in terms of syntax and native functionality. $a=$page->related; $array = explode("|", $a); if ($a->count()) { echo '<h2>'.$a->getTotal().' Related Entries</h2>'; echo '<ul>'; foreach ($array as $key => $value) { $link = $pages->get($value)->httpUrl; $title = $pages->get($value)->title; $out = '<li><a href="'.$link.'">'.$title.'</a></li>'; echo $out; } echo '</ul>'; }
  7. Hello, I have a fieldtype Page named 'category' in my pages. I want to find pages from several categories like this: $teaser=$pages->find("template=video,category.id=17|19|23,sort=-created"); This works great. Now I try the same thing on "my own" pageArray: $sql = "select distinct video from views order by created desc"; $result = wire('db')->query($sql); $bw = new PageArray; while($row = $result->fetch_array()) { if($video = $pages->get($row['video'])->id) $bw->add($video); } $teaser=$bw->filter("template=video,category.id=17|19|23"); ... now $teaser contains nothing. It works well when I leave out "category.id=[...]" in the filter ... Can anyone help? Thanks, thomas
  8. Hey, I have a tournament page that requires teams competing in that tournament, this can be more then 2 it can be 100+ so I thought i get a page array but how do i use it in the template? i tried: foreach($page->teams as $team); { echo $team->title; } But then I'd only get the last team... how do i get this right?
  9. Greetings, I wonder if anyone can help me understand how to overcome this issue. I am building a simples catalog with 3 taxonomy: category (determined by hierarchical page), type and area (both are selected using PageArray dropdowns, meaning that the Options are "pages" which have attributes themselves. Now, I want to create a search-like template that picks up the URL arguments, but I don't know how to set this correctly. I picked up the search.php example, and added category restriction, but now I want to also restrict by 'area'. $matches = $pages->find("title|body|sidebar*=$q, parent=/catalogo/produtos/, arealimit=50, id!=1"); The area attribute has 4 items, all of them have title, description and a field called 'alias'. I would like to search by alias, and return all products that have that 'area' selected. The URL should look like this: domain.com/catalog-search/?q=carro&area=RH Now, I want to pickup the 'area alias' typed in the URL (which I already have), check to which 'area' this alias belongs, and use that area to filter my results. Since there can be multiple areas selected, how can that "search query" be built? Thank you very much for any help.
  10. Hello, I have a function that creates a PageArray, throws a bunch of pages into it and returns it. Now I'd like to use all the PageArray methids on it but for some reason, everything after the first selector is ignored. The function: function getRelated($pageTags,$template,$limit=1000) { $pages = wire('pages'); foreach($pageTags as $tags) { $tag = wire('sanitizer')->selectorValue($tags->title); if($template) $templateQ = ",template=$template"; $related_pages = $pages->find("tags.title=$tag,id!=".wire('page')->id.$templateQ); foreach($related_pages as $related) { $related_id[$related->id]++; } } $rp = new PageArray(); foreach($related_id as $key => $val) if($tmp++ < $limit) { $rel_page = $pages->get($key); $rel_page->rank = $related_id[$key]; $rp->add($rel_page); } return $rp; } How I'd like to use it: $rel = getRelated($page->tags); $start = $input->urlSegment1 | 0; $related = $rel->find("sort=-rank,sort=-created,start=$start,limit=3"); This returns all the elements in $rel, sorted by rank, everything else is ignored. Is this a bug I built or a bug I found? Thanks, thomas
  11. First of all, my congratulations to Ryan on this amazing piece of software! This is my first post in these forums, but I have been a silent noob for a few months, learning while using processwire for every web project in the Multimedia Design course I'm currently finishing! On to the bug/problem (is this the right place for this post?) : When I try to sort a PageArray object using the $a->sort() method on a string field, say, the title, the API places the ones starting with uppercase first, and the lowercase last, like so: A,B,C,D,a,b,c,d... Am I doing something wrong/missing something? Cheers, Tiago
×
×
  • Create New...