-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
Ok I get it. Good to know this is possible. Though I'm not sure I'll set this up in this site. There's not sooo many fields I'm using in the search and there's some multilang fields on templates, so it would need 3 cache fields for some "_de,_en,_fr", or include them all in one an sort page out from other language trees.... This can get cumbersome and not so easy to maintain. I like it to have it in code form. What you mean when you speak of lots of fields? My selector part is now like following and there will be max of like 200-300 pages/downloads/properties/contacts total for a language. Do you think caching fields would really make a difference? I didn't notice any impact yet without cacheing. <?php $q = $sanitizer->selectorValue($input->post->q); $words = explode(' ', $q); foreach($words as $word) { $word = $sanitizer->selectorValue($word); if($word) $selectorPages .= "title|headline|headline2|body|summary%=$word, "; if($word) $selectorObjects .= "title|beschreibung_$lang|strasse|ort|bewirtschaftung|hauswart_adresse|headline1_$lang|headline2_$lang%=$word, "; if($word) $selectorEmergencyContacts .= "title|label_$lang%=$word, "; if($word) $selectorDownloads .= "title%=$word, "; }
-
Ahh now I get it! But with lots of fields in 3 languages its quite tedious to set up. Nonetheless its a great feature. Now I did what you said and hit save, but there's no cache created. If I check "regenerate cache" and hit save it throws an error Cache 'emergency_contacts_field_cache' is not assigned to any templates. What now? Do I need to attach that field to templates too?
-
Progress on ProcessWire 2.2 and overview of multi-language support
Soma replied to ryan's topic in Multi-Language Support
I could help out with de-DE or ch-CH (swiss german, would be funny) -
I already wondered what this module is about and for what use? Example? Is it to have a selectable list of custom modules that then will get executed on template file / page? Sorry if I missed the obvious.
-
It shows on modules overview that it's configurable, but when opening there's nothing to configure.
- 1 reply
-
- 1
-
-
Thanks you a lot Ryan for the input. Very helpful! Just one thing I don't get, what you mean by cache field? I don't get it.
-
Nico, don't know if you seen the CSV import module by Ryan in the download section... https://github.com/ryancramerdesign/ImportPagesCSV
-
Not sure, it works for me. What browser? PW version?
-
I'm currently using this module to render simple contact form and it works great so far. Now I got a page reference field with a select inputfield for selecting a category. These categories are pages and they are multilang. So there's 3 fields for title_de, title_en, title_fr. How would it be possible to render the select chosing the option text from the current language? So far I've added a parameter to the ___render($lang) function and give that to the ___buildForm function where the form is built. How can I make it (if ie inputfield->name is "category_select") using like "title_$lang" for the option text. Or maybe simpler /alternatively, how can I build the select menu using API? Any help is appreciated. EDIT: I should first investigate.. then ask I found the simplest solution: <?php if($inputfield->name == "formfield_category_select"){ $inputfield->labelFieldName = "title_$lang"; } This sets the field chosen from the reference pages for the inputfield select. Amazing, didn't thought it was that simple. EDIT: Only problem now the select has id's as value which get sent by email, how could I set the option value to be the title? EDIT: Well I think this wouldn't be easy possible, no? Now what I did is a simple check, when preparing the mail content for sending email, for the fieldtype label. If it's the category select, I do a find using the id and return the title_de, title_en ...
-
I just tested some more and it was me getting confused, but I can confirm it works with multiple matches. Now I notice a problem concerning multiple words, using any of the *= %= ~= . I search for : "lift notfall" = no results. "lift" = 4 results ("notfall" doesn't relly exist somewhere) This is on a search over simple fields: title|textfield|textfield Edit: Ok I understand it that "~" is only if all words exactly match. It doesn't match only parts of words like with %. But when using % it doesn't search with multiple words. How would it be possible to archive this having multiple words? I know search is not an easy topic and I've done it only roughly few times in the past, last doing it using Doctrine ORM with CI and performing index searches using Doctrine Search, was hard to find the right way that's working fine with multiple words. Like searching for "zeit bern" it finds "Berner Zeitung".
-
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.
-
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?
-
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.
-
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
-
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! )
-
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.
-
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....
-
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.
-
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.
-
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;
-
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.
-
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);
-
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.
-
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>"; }
-
Hi kasperwf and welcome You might want to check out this redirect module: http://processwire.com/talk/index.php/topic,171.0.html