Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Thanks Ryan for the help. I'm doing tests with this a little more, but cases I thought where not giving results but should with multiple phrases, I mean part of words. Only having exact phrases will not always find the desired. As for the page reference search I'm still having some issue, but I'm sure it's me. Will maybe come back. But this should work with multiple contacts found no?, and then find pages with having at least one contact (there's multiple) page reference out of this page array? Hope this makes sense.
  2. It works like a charm. Now I can't help but this amazes me more and more, I'm working on a pretty big and more "complex" site (multilang) and with the way PW works, I love how I can do a very powerful search with very simple readable maintainable code. Run multiple searches and combine them before output, and then being able to sort them by whatever and listing them differently depending on type (ie downloads, pages, addresses ...). It's so fun! EDIT: Only thing that's now bothering me is that multiple word searches don't seem to work over multiple fields well. I have problems to decide which to chose from *%~ . Any tips on this?
  3. Was just about to write a foreach loop when I've seen your response. Ahh sure, forgot almost there's no need for loops here! Thanks a lot Ryan for giving the most amazing code example on planet earth. Love it!!! I don't know of any other system that would do this with just two short lines! Perfect.
  4. Is it possible to search for pages having a multi page reference field? Like it's possible with: image.description*=phrase I have built pages of properties containing a page reference field of some emergency addresses with phone numbers. Those addresses are separate pages which can be selected. Now would it be possible, when performing a search, to find pages with having a reference to a address containing the search term?. EDIT: I just figured a straight forward easy way of accomplishing this. Doing a search in addresses first for a matches then do another search for property pages having a page reference to one of the address pages. Will try after a shower
  5. To avoid such things for updates, I think it might be a good idea to have a board dedicated to this, whith a sticky up-to-date post? ( just noticed, it's my 300th post! )
  6. While I'm in need of a html php parser I found this one: http://simplehtmldom.sourceforge.net/ It's a pretty cool jQuery style PHP lib for parsing and manipulating HTML DOM.
  7. Yeah that's pretty much it BDH. Nice one, that will do it even recursively. My example is only for a 2level approach and what I'm doing is to hide the sublevel using css and put a display:block only if active. But it was more to show the conditions....
  8. Actually something like this is on the roadmap, but timeline is roughly aug.2012 http://processwire.com/about/roadmap/ But you could do it already using children pages. You can access them in the parent pages template in a foreach loop and even have different templates for each "sub-page" to select from. They don't even need to have a .php file, but you could still add one to do a a simple $session->redirect($page->parent->url); to the parent page if it's being accessed directly from a search result for example. With this you can also sort them and extend it easily. Or you could have the templates populate html markup like a list or box, and then use the page render() method (which is a module in PW) on the parent template to simply render them out. Make them hidden or exclude them from the navigation with using a selector. - A simple code snippet (or more complex) could be used to handle all. <?php $templ = "template=elem-body|elem-image-text|elem-title|elem-video"; if($page->children($templ)->count() > 0){ foreach($page->children($templ) as $elem){ echo $elem->render(); } } ?> So this approach can be very powerful and simple. PW is designed to work very well this way. Not sure if something like this could be useful in your case, but just wanted to give a alternative.
  9. CI index.php ... include("./pw/index.php"); require_once BASEPATH.'core/CodeIgniter.php'; it works fine. latest CI and PW in a subdirectory /pw ... i can in welcome_message.php output pw pages... I just tried because I also plan to use both for a project. Great possibilities! <?php // in CI view files... $pa = wire("pages")->get('/')->children(); foreach($pa as $child){ echo $child->title."<br/>"; } Edit: You can even use it in controllers, or use the render method to output whole page markup. Though depending on the setup and paths this doesn't load images or css/js but maybe a htaccess could fix this. Not sure yet how far you can combine these two frameworks, but doing well so far. <?php $pa = wire('pages')->get("/about/"); $pa->setOutputFormatting(true); echo $pa->render(); Edit: You can also include PW index.php using a CI processwire_helper.php and autoload it. So wire is available in all view and controllers.
  10. sorry for ignoring you kinda I slightly modified a code I'm using, it should do what you need, but you may need to modify to your needs. Key is to check for $page->parents->has($child) and $child === $page->parent and the like to add a style="display:block" to the sub ul. <?php $p = $pages->get("/"); $out = ''; foreach($p->children as $child) { // check if this child is in parents or direct parent of current page if($page->parents->has($child) || $child === $page || $child === $page->parent) $class = "on"; else $class = ''; $out .= "\n<li><a class='$class' href='{$child->url}'>{$child->title}</a>"; if($child->numChildren > 0){ // check if this child is in parents or direct parent of current page if($page->parents->has($child) || $child === $page || $child === $page->parent) $status = " style='display:block'"; else $status = ''; $out .= "\n\t<ul$status>"; foreach($child->children as $childchild) { if($childchild === $page || $childchild === $page->parent) $class = "on"; else $class = ''; $out .= "\n\t\t<li><a class='$class' href='{$childchild->url}'>{$childchild->title}</a></li>"; } $out .= "\n\t</ul>"; } $out .= "\n</li>"; } echo $out;
  11. Thanks a lot slkwrm, very nice of you, but that's not what I wanted. Look at my optimized code it does perfectly what I need. I just output when on a certain level, so it always needs 2 checks for parent to show children level and on next level to output its siblings. But I also was thinking of more complicated scenario with having 2-3 sublevels more with that technik and maybe also have a further "invisible" level but still highlighting the parents... I now how it can be done, it just gets little more complicated and thought if there's another way I dont know.
  12. Thanks slkwrm, but I know that and I have no problems with straight recursive from top navigations. maybe I could try the navigation function from apeisa to only output a certain level depending on the current page "tree path"... EDIT: I simplyfied my first horror code example from a few weeks ago to the following. One minor thing Ryan, the $page var doesn't work inside the scope of the function. <?php $templates = "template=sub-page|sub-page-wide|list-sub-page|sub-page-iframe"; function renderPageList($children,$page){ $out = "<div class='content-nav'>"; foreach($children as $child){ $class = $child === $page ? " on" : ''; $out .= "\n\t\t<a class='ajaxy-page{$class}' href='{$child->url}'>$child->title</a> | "; } $out = substr($out,0,strlen($out)-2) . "</div>"; return $out; } if(count($page->parents) == 3 && $page->numChildren > 0) echo renderPageList($page->children($templates),$page); if(count($page->parents) == 4 && $page->parent->numChildren > 0) echo renderPageList($page->parent->children($templates),$page);
  13. Thanks a lot Ryan, I know it can be simplyfied using a function like you showed. The main problem I think is with more complicated scenarios with more sublevels and such, if having to always going relatively from the current page it's really hard to get the whole logic right.
  14. How can I create a level dependent subnavigation? Like I want to only echo the 3-level of the page tree relative to the current page. I tried to creates something, but it gets to complicated for my liking. Maybe I'm missing the obvious. Following code I check how many parents there are form the root and depending on that output childs or siblings. <?php // start building content navigation on top $content_nav = ''; // build 4th level navigation only foreach($page->parents as $level => $p){ // build when on 2th level if(count($page->parents) == 3){ if($level == 2 and count($page->children) > 0){ $p3 = $page; $out = ''; $found = $p3->children("template=sub-page|sub-page-wide|list-sub-page|sub-page-iframe"); if($found){ foreach($found as $child){ if($child === $page) $class = " on"; else $class= ''; $out .= "\n\t\t<a class='ajaxy-page{$class}' href='{$child->url}'>$child->title</a> | "; } $content_nav = "\n\t\t<div class='content-nav'>"; // remove last 2 chars from string to remove last "|" $content_nav .= substr($out,0,strlen($out)-2)."</div>"; echo $content_nav; } } } // build when on 3th level if(count($page->parents) == 4){ if($level == 3){ $p3 = $p; $out = ''; $found = $p3->children("template=sub-page|sub-page-wide|list-sub-page|sub-page-iframe"); if($found){ foreach($found as $child){ if($child === $page) $class = " on"; else $class= ''; $out .= "\n\t\t\t<a class='ajaxy-page{$class}' href='{$child->url}'>$child->title</a> | "; } $content_nav = "\n\t\t<div class='content-nav'>"; // remove last 2 chars from string to remove last "|" $content_nav .= substr($out,0,strlen($out)-2)."</div>"; echo $content_nav; } } } } I have a simpler example which is better I think, but I would love to may hear alternatives, or ideas although I can't think of anything else atm. <?php if($page->parents->count() == 3 and $page->numChildren > 0) { echo "<ul>"; foreach($page->children as $child){ $class = $child === $page ? 'class="active"' : ''; echo "\n<li><a href='$child->url' {$class}>{$child->title}</a></li>"; } echo "</ul>"; } if($page->parents->count() > 3) { echo "<ul>"; foreach($page->parent->children as $child){ $class = $child === $page ? 'class="active"' : ''; echo "\n<li><a href='$child->url' {$class}>{$child->title}</a></li>"; } echo "</ul>"; }
  15. Hi kasperwf and welcome You might want to check out this redirect module: http://processwire.com/talk/index.php/topic,171.0.html
  16. I deleted mine... I agree with all.
  17. Ah.. ok then I understand and I will delete comment. Thanks! Or not?
  18. ::alert:: There's acutally a visual indicator that a module is configurable (gear), I've spent a day looking through all possible settings there. Not sure if you're talking about PW2 or PW2.1.
  19. Some great RT on twitter! Snowball is running soon to become an avalanche... EDIT: It's crazy, search for processwire on twitter and wait ...
  20. This is really great to see coming soon. Awesome! Interesting read and well done. Will try out as soon as I can. Thanks for doing it again!
  21. NP. I feel stupid all the time, that's why I continue trying not to be stupid.
  22. Thanks for your input apeisa and these are valid things to consider when implementing such a thing. I don't consider this being much configurable, but a moduel sounds great if that would be possible Ryan! Any way I can help, just message me. Mainly The CMS we use has like a time out I think by RPC ping, so not possible to have it locked for any longer than the session time out I guess (not sure really, I never bothered looking at the code). So after not working on for maybe 30min, it will lose connection and page will be unlocked.
  23. You can change it in the setting of the Page List Process Module.
  24. Thanks Ryan, I somehow missed that by not looking close enough That's great to know and now works as expected.
  25. It does lock it in the CMS we use and no wa to unlock it till the other closes browser or page. This has never ever caused problem but prevented them. For our clients and projects it's a needed feature 100% of the time, because there large group of editors having access to same pages, often it would be overkill or even not possible to manage access for each page seperate. I agree that it doesn't happen often but when... We or I would even sponsor it if needed.
×
×
  • Create New...