-
Posts
7,529 -
Joined
-
Last visited
-
Days Won
160
Everything posted by kongondo
-
@Nik, Works a treat! Thanks Thanks for the tip as well.
-
Ability to translate username different from pagename
kongondo replied to apeisa's topic in Wishlist & Roadmap
I don't think he meant the address bar? Apeisa, do you mean the label "Name*", in the first field when editing page settings.See screenshot. I could be wrong...I have been before -
Thanks Ryan.
-
I have been banging my head about this for a while so I reckoned let me pick your brains instead I have a recursive function pinched from SO that loops over and outputs some records... <?php function listProducts($productCat,$level=0) { $result = wire('db')->query("SELECT id, product, productcat FROM products WHERE productcat='$productCat' ORDER BY subcat"); if($result->num_rows == 0) return; echo "<ul class='sortable'>\n"; while (list ($id, $product) = $result->fetch_row()) { echo "<li id='item_{$id}'>\n"; echo "<div class='dd-handle'>{$product}</div>\n"; listProducts($id,$level+1); echo "</li>\n"; } echo "</ul>\n"; } ?> <div> <h5>Products</h5> <ul class="sortable"><?php echo listProducts(0);//call the function ?></ul> <!-- problem --> </div> Code works just fine. However, what I need to do is to conditionally output the <ul> in the function depending on whether records are found or not like so: if($result->num_rows == 0) { echo "<ul class='sortable'></ul>\n";// echo empty ul if no products found } else { echo "<ul class='sortable'>\n";// echo opening ul tag if products found } This is because I am adding product items to the <ul> using jQuery. If there are no products, I need an empty <ul></ul> to append my product items to. If there are product items, no need to echo the empty <ul></ul>, just echo the opening <ul> tag and the function will close it properly later on. If I do it like this, the code doesn't work properly. If there are no results, I don't get my empty <ul></ul>. If there are records, I am getting extra/unnecessary empty <ul></ul> after each <li></li>. I have tried different things including $result->fetch_array (); then doing an if against that but without success. If I manually add the empty <ul></ul> when I call the function (like in my example above) I will of course still get empty extra <ul></ul> when I call the function and there are records. It's either this or resorting to querying the db again outside the function to check if there are records and echoing empty <ul></ul> if there aren't...etc. Hope this makes sense and thanks for your help. Sorry for the long-winded <ul>s!
-
You are on the right track (looked at this quickly). In those "rare cases" you mention you will want to use multiple page reference fields, of course. As for search functionality, yes that can be done. Look at the Skyscrapers site/profile to get you started. dl profile: http://mods.pw/3T example: http://processwire.com/skyscrapers/ If you have more specific questions regarding "search", I'd suggest opening a new thread tailored to those questions so that they can be picked up quickly/easily. Edit: Added useful links http://processwire.com/talk/topic/3325-filter-results-via-multiple-dropdowns/ http://processwire.com/talk/topic/2491-skyscrapers-profile/ http://processwire.com/talk/topic/1526-selectors-get-architects-from-city-buildings/ http://processwire.com/talk/topic/571-simple-drop-down-search/
-
Oops, Diogo, I forgot to respond to your question above! No undesirable effects (older version). I haven't had time to test the latest version of the module. Will do so soon and report any issues. Thanks for the release!
-
Same here...Marc's article was the tipping point for me as well...
-
Roope, Thanks for clarifying!
-
Well-said Matthew! I still can't believe that I can "write php" code, thanks to ProcessWire! The API - it's friendliness and power - has encouraged me to write code. I don't think I would have dared to code a single line of snippet in MODX save for echo "Hello World"; ! It's not a problem with MODX; it's just that PW makes many difficult things easy. choppingblock, I think I have said welcome before; if not, welcome to PW! Cheers.
-
Welcome Alex! Ex-MODX-er here. Yes, PW is really awesome Our resident image (exif) etc expert is a guy called Horst. He (and others) will give you a better answer than me. Maybe the following threads would be helpful? http://processwire.com/talk/topic/238-creating-pages-using-api/ http://processwire.com/talk/topic/3219-images-manager-alpha/?p=33485 http://processwire.com/talk/topic/3398-working-with-processwire-getting-exif-data-from-images/
-
Shouldn't it be wire ('page') instead because you are in a function? //note: newbie here; don't take my word for it Btw, just curious, what's the difference your module and Ryan's? http://mods.pw/j
-
You mean this http://processwire.com/api/hooks/captain-hook/ and probably this http://processwire.com/api/hooks/ too?
-
WP Same initials - other way round!
-
Btw, how can I easily sanitize the $key=> $value pairs? The $key is straightforward because it will always be an integer. So I can do this? $x = (int) $key; or should I sanitize earlier at the $input->post->list? The $value is tricky because it could be an integer or it could be the string "root". Maybe use an if on this one? Thanks.
-
Thanks Wanze for the additions. In my case, I am sure that the array was not empty so the warning was due to foreach not liking the serialized string... Edit: Just to clarify. The warning would occur even outside PW. It had nothing to do with PW methods.
-
I wonder how many of those Switzerland and USA visits are down to you know who ! Jokes aside, nice stats!
-
Does the presence of spam on the forums mean we are becoming more popular? I've encountered a couple this week. Either way, I think PW is becoming more popular. My take, it's more popular in Europe than other regions?
-
Think I tried this earlier but can't remember the outcome; tried so many things! Thx. This takes away the Warning but the code doesn't work; cannot save to DB Works like a charm, thanks! For fellow-newbies, I used this like so if (isset($input->post->list){//access as object property $i = 0; foreach($input->post->list as $key => $value){ blah blah... } //this also works //if (isset($input->post['list']))//access as array index } <cliche>I owe you one Soma!</cliche> ps: If you have a minute, please explain why this works....and I thought I knew what isset does
-
Hi, This is not PW-specific so not sure if I am posting in the right board. I have a PW page with a jQuery ajax call that serializes some values and sends them by POST like so: list[7]=root&list[2]=root&list[5]=2&list[4]=root&list[3]=4&list[6]=root&list[8]=6&list[1]=8 These are sent to another PW page for processing. I have the following code. It works fine but I get an "Invalid argument supplied for foreach() in..." error (in the example I haven't sanitized anything; will do so in final version ). $i = 0; foreach ($input->post ['list']as $key => $value) {//values to be sanitized; this is a basic example $x = $key; $y = $value; $z = $i; $i++; if ($y == "foo") { $y = "bar"; } //do other stuff with $x, $y and $z } Although the code works, I'd like to get rid of the warning. I know foreach expects an array in this case so ideally, I would want to convert the serialized string to an array first. That's where I am getting stuck (searched StackOverflow, etc ). I also know I could use jQuery toArray but that sends some other value pairs that I don't need. I think "serialize" is simpler to use. Maybe explode the string? Overkill for this? Thanks for any pointers! Cheers /k Edit: Just to clarify. The warning would occur even outside PW. It had nothing to do with PW methods.
-
Micha, Thanks for this module. For reference for all reading this, these "tags" have been discussed previously in this thread: http://processwire.com/talk/topic/2689-possible-to-get-field-tags/. See Ryan's thoughts on post #21.
-
Well done Horst! Sorry didn't have time to test the last version. Will make some time for this
-
Thanks guys!
-
@Matthew, thus far, it seems it's only people in the States who can't view it?! You and Ryan...strange..