janlonden
Members-
Posts
45 -
Joined
-
Last visited
Everything posted by janlonden
-
CSS frameworks are way too bloated in my opinion. I guess they might be useful if you have a huge site with lots of content. I like to keep things as simple as possible. Here's my "framework": Grids sizes: /* 1 8.333333333333333% 2 16.66666666666667% 3 25% 4 33.33333333333334% 5 41.66666666666667% 6 50% 7 58.33333333333334% 8 66.66666666666667% 9 75% 10 83.33333333333333% 11 91.66666666666667% */ Box-sizing, for layout elements especially, allows you to add margin/padding/border without having to worry about changing width to fit margin/padding/border – best thing since ... ProcessWire. * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } Layout elements, for example: #content { float: left; width: 66.66666666666667%; } #sidebar { float: left; width: 33.33333333333334%; } I also use normalize and boilerplates cross browser normalizing stylesheet.
-
Cool gallery website! Some critique: The main menu is a catastrophe in my opinion. The rounded corners on the left and right bottom side plus the margin between the links doesn't look good. The gallery loader.gif has a black background, which doesn't work with the blue background of the site. I would switch the keyboard arrow navigation. Right for next img, left for prev. More intuitive that way.
-
Yeah whatever works I also like to use PHP tags in HTML, being a designer.
-
Thanks Ryan for the tip! But I decided to use a different approach. See my post above your post and tell me your thoughts on it
-
Thanks kongondo! This is what I came up with after reading some of those articles: <?php $books = $page->children($selector); ?> <?php if (count($books)) : ?> <ul> <?php foreach($books as $book) : ?> <li> <p> <a href="<?=$book->url?>"><?=$book->title?></a> Publisher: <?=$book->book_publisher?><br> Number of chapters: <?=$book->book_chapters?><br> Number of pages: <?=$book->book_pages?> </p> </li> <?php endforeach ?> </ul> <?php else : ?> <p>No books were found.</p> <?php endif ?> Much better, right? This style of coding reminds me of the past when i used to use WordPress
-
A much better output with this: <?php $books = $page->children($selector); if (count($books)) { echo "<ul>\n"; foreach($books as $book) { echo "\t<li>\n" . "\t\t<p>\n" . "\t\t\t<a href='{$book->url}'>{$book->title}</a><br>\n" . "\t\t\tModel: {$book->book_publisher}<br>\n" . "\t\t\tResolution: {$book->book_chapters}<br>\n" . "\t\t\tSize: {$book->book_pages}\n" . "\t\t</p>\n" . "\t</li>\n"; } echo "</ul>\n"; } else { echo "<p>No books found.</p>"; } ?>
-
Yeah I got that feeling myself intuitively If you or anyone could help me make this better that would be great! I´ll try to figure out how to remove those echoes.
-
I wrote my own code which works. Haha I´m feeling like a PHP pro right now $photos = $page->children($selector); if (count($photos)) { foreach($photos as $photo) { echo '<ul>'; echo '<li><a href="'.$photo->url.'">'.$photo->title.'</a></li>'; echo '<li>Model: '.$photo->camera_model.'</li>'; echo '<li>Resolution: '.$photo->photo_resolution.'</li>'; echo '<li>Size:'.$photo->photo_size.'</li>'; echo '</ul>'; } } else { echo '<p>No photos found.</p>'; } ?> I have no idea if this is good PHP coding practice or not, but it works
-
One thing it still lacks is a "no photos found" text. How would I do that?
-
It does feel really good Thank you again for your help! I switched to integer and now it works. The fields are now sanitized also, using this: if($input->get->photo_resolution == 'asc') { $value = $sanitizer->selectorValue($input->get->photo_resolution); $selector .= "sort=photo_resolution,"; $summary["photo_resolution"] = $sanitizer->entities($value); $input->whitelist('photo_resolution', $value); } elseif($input->get->photo_resolution == 'desc') { $value = $sanitizer->selectorValue($input->get->photo_resolution); $selector .= "sort=-photo_resolution,"; $summary["photo_resolution"] = $sanitizer->entities($value); $input->whitelist('photo_resolution', $value); } Is this correct? I get no errors at least.
-
One thing I don't understand is why it sorts the "photo_resolution" from lowest to high as: 1024, 2048 and 480. It seems that it only counts the first number. I had the same problem with Hero Framework CMS. Any ideas how to fix this?
-
I think I got them working! Just had to change som asc/desc values. The resolution and size sortings may clash because of the similarity of their values, plus having only 3 pages to sort doesn´t help. I also manages to code and get the selected="selected" working! All by myself! With this code: <label for="camera_model">Camera model</label> <select name="camera_model" id="camera_model"> <option value="desc"<?php if ($input->get->camera_model == 'desc') { echo ' selected="selected"'; } ?>>Alphabetically A-Z</option> <option value="asc"<?php if ($input->get->camera_model == 'asc') { echo ' selected="selected"'; } ?>>Alphabetically Z-A</option> </select>
-
As I said, I´m with you on using seperate selects That "splitting" technique might be the answer to the problem with the select options? How would i do that splitting with the multiple select tags version?
-
Yeah I guess you´re right. It is possible and useable to combine the options. But there´s still problems with changing the options. If I play around with the options I might succeed changing one of them. And if i then want to change that option I have to click around with the others to change the previous option. Hard to explain But yeah it´s not working properly. Could it be because there´s just one value for "asc" and one for "desc"?
-
Thanks, I´ll check that one out. I think the options worked but they would work even better if I´d put them on one single select tag of course. I mean I cannot sort them by more than one custom field at a time. Not in this case atleast, right? Stupid me I need them to be like this: <p> <label for="sort_photos">Sort by</label> <select name="sort_photos" id="sort_photos"> <optgroup label="Alphabetically"> <option value="desc">A-Z</option> <option value="asc">Z-A</option> </optgroup> <optgroup label="Resolution"> <option value="desc">Highest to low</option> <option value="asc">Lowest to high</option> </optgroup> <optgroup label="Size"> <option value="desc">Highest to low</option> <option value="asc">Lowest to high</option> </optgroup> </select> </p> Any ideas how to code the PHP part?
-
Thanks adrian. It´s almost working now! The search works just fine. The others work like, once after I´ve used the search, and then they stop working. The code: <?php $selector = ''; if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } if($input->get->camera_model == 'asc') { $selector .= "sort=camera_model,"; } elseif($input->get->camera_model == 'desc') { $selector .= "sort=-camera_model,"; } if($input->get->photo_resolution == 'asc') { $selector .= "sort=photo_resolution,"; } elseif($input->get->photo_resolution == 'desc') { $selector .= "sort=-photo_resolution,"; } if($input->get->photo_size == 'asc') { $selector .= "sort=photo_size,"; } elseif($input->get->photo_size == 'desc') { $selector .= "sort=-photo_size,"; } ?> <form id="photo_search" method="get" action="<?php echo $config->urls->root?>photos/"> <h3>Browse photos</h3> <p> <label for="search_keywords">Keywords</label> <input type="text" name="keywords" id="search_keywords" value="<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>" /> </p> <p> <label for="camera_model">Camera model</label> <select name="camera_model" id="camera_model"> <option value="desc">Alphabetically A-Z</option> <option value="asc">Alphabetically Z-A</option> </select> </p> <p> <label for="photo_resolution">Photo resolution</label> <select name="photo_resolution" id="photo_resolution"> <option value="desc">Highest to low</option> <option value="asc">Lowest to high</option> </select> </p> <p> <label for="photo_size">Photo size</label> <select name="photo_size" id="photo_size"> <option value="desc">Highest to low</option> <option value="asc">Lowest to high</option> </select> </p> <p> <input type="submit" id="photo_submit" name="submit" value="Find" /> </p> </form> <?php $photos = $page->children($selector); foreach($photos as $photo) { echo '<ul>'; echo '<li><a href="'.$photo->url.'">'.$photo->title.'</a></li>'; echo '</ul>'; } ?> I suspect there´s something wrong with the upper PHP part, the ifs and elses.
-
My page structure is photos > photo1, 2 etc..
-
Thank you both kongondo and adrian for taking the time to help. I read both of those posts and tried the codes in them but couldn't get them to work. I also tested adrians new code, which just displays a unordered list of the photos and where the search doesn´t work. I think i need to add something like this: <?php $selector = ''; if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } // add something here, like: if($input->get->camera_model) { $selector .= "template=photo sort=camera_model"; $selector .= "template=photo sort=-camera_model"; } ?> And then in the form add $selector or some other php to <select> camera_model and camera_resolution. <form id="photo_search" method="get" action="<?php echo $config->urls->root?>photos/"> <h3>Browse photos</h3> <p> <label for="search_keywords">Keywords</label> <input type="text" name="keywords" id="search_keywords" value="<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>" /> </p> <p> <label for="camera_model">Camera model</label> <select name="camera_model" id="camera_model"> <option>Sort alphabetically(Ascending)</option> <option>Sort alphabetically(Desdending)</option> </select> </p> <p> <label for="camera_resolution">Camera resolution</label> <select name="camera_resolution" id="camera_resolution"> <option>Highest to low</option> <option>Lowest to high</option> </select> </p> <p> <input type="submit" id="search_submit" name="submit" value="Search" /> </p> </form> Any help would be greatly appreciated. ProcessWire is such a great system otherwise which is why I´m willing to go through this trouble to get this working. I just tested the views module in drupal 7. With just a few clicks I had a nice custom query thingy. I wish ProcessWire had something similar
-
Thank you for your help. This is what I´ve managed to come up with: <?php $images = $page->children($selector); if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } ?> <h1>Browse photos</h1> <form id="photo_search" method="get" action="<?php echo $config->urls->root?>browse/?>"> <p> <label for='search_keywords'>Keywords</label> <input type='text' name='keywords' id='search_keywords' value='<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>' /> </p> <p> <input type="submit" id="search_submit" name="submit" value="Find" /> </p> </form> <?php foreach($images as $image) { echo $image->url; } ?> ... As i said, I´m a total PHP noob. This won't even display the search results I looked at the selector page and found that the code below works to display the photos by model/resolution/size. $photos = $pages->find("template=photo, sort=camera_model"); foreach($photos as $photo) { ... } But how to implement that into the search form i have no idea. Maybe I´ll have to settle for a single select input which links to pages with custom querys?
-
Hi! I´m really liking ProcessWire, even though it´s a little intimidating to a complete PHP noob like me. The basics are pretty easy understand, but one function I still lack is the option to sort pages by custom fields. I looked at Ryans Scryscraper Site Profile to try to figure out how he did it for about 5 minutes before my brain exploded. I´ve also tried to search the forums without success. So if this is something that some of you PHP gurus could help me with that would be awesome. Here´s my question. Lets say I have a photos page with lots of photo pages in it which include custom fields such as resolution, camera, size etc.. How would i go about to list them by these fields? For example like this: select -option(Camera model from A-Z) -option(Camera model from Z-A) select -option(Highest resolution) -option(Lowest resolution) select -option(Highest size) -option(Lowest size) [Find] Thank you. /Jan Londén Edit: Here´s the final code. Remember this is an ugly copy/paste version from a non PHP programmer. Use at your own risk, etc.. If anyone wants to improve, make this more elegant, please do. Huge thanks to adrian who helped a lot. <?php /** * Books template * */ include("./head.inc"); $selector = ''; // For the keyword search input. Searches both title and body. if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } // For the book publisher select tag. Sorts alphabetically from A to Z. if($input->get->book_publisher == 'desc') { $value = $sanitizer->selectorValue($input->get->book_publisher); $selector .= "sort=book_publisher,"; $summary["book_publisher"] = $sanitizer->entities($value); $input->whitelist('book_publisher', $value); } // From Z to A. elseif($input->get->book_genre == 'asc') { $value = $sanitizer->selectorValue($input->get->book_genre); $selector .= "sort=-book_genre,"; $summary["book_genre"] = $sanitizer->entities($value); $input->whitelist('book_genre', $value); } // For the book chapters select tag. Sorts numerically from highest to lowest number of pages. if($input->get->book_chapters == 'desc') { $value = $sanitizer->selectorValue($input->get->book_chapters); $selector .= "sort=book_chapters,"; $summary["book_chapters"] = $sanitizer->entities($value); $input->whitelist('book_chapters', $value); } // From lowest to highest. elseif($input->get->book_chapters == 'asc') { $value = $sanitizer->selectorValue($input->get->book_chapters); $selector .= "sort=-book_chapters,"; $summary["book_chapters"] = $sanitizer->entities($value); $input->whitelist('book_chapters', $value); } // For the book pages select tag. Sorts numerically from highest to lowest number of pages. if($input->get->book_pages == 'desc') { $value = $sanitizer->selectorValue($input->get->book_pages); $selector .= "sort=book_pages,"; $summary["book_pages"] = $sanitizer->entities($value); $input->whitelist('book_pages', $value); } // From lowest to highest. elseif($input->get->book_pages == 'asc') { $value = $sanitizer->selectorValue($input->get->book_pages); $selector .= "sort=-book_pages,"; $summary["book_pages"] = $sanitizer->entities($value); $input->whitelist('book_pages', $value); } ?> <form id="book_search" method="get" action="<?php echo $config->urls->root?>books/"> <h3>Browse books</h3> <p> <label for="search_keywords">Search</label> <input type="text" name="keywords" id="search_keywords" value="<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>" /> </p> <p> <label for="book_publisher">Publisher</label> <select name="book_publisher" id="book_publisher"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_publisher == 'desc') { echo ' selected="selected"'; } ?>>Alphabetically A-Z</option> <option value="asc"<?php if ($input->get->book_publisher == 'asc') { echo ' selected="selected"'; } ?>>Alphabetically Z-A</option> </select> </p> <p> <label for="book_chapters">Number of chapters</label> <select name="book_chapters" id="book_chapters"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_chapters == 'desc') { echo ' selected="selected"'; } ?>>Highest to lowest</option> <option value="asc"<?php if ($input->get->book_chapters == 'asc') { echo ' selected="selected"'; } ?>>Lowest to highest</option> </select> </p> <p> <label for="book_pages">Number of pages</label> <select name="book_pages" id="book_pages"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_pages == 'desc') { echo ' selected="selected"'; } ?>>Highest to low</option> <option value="asc"<?php if ($input->get->book_pages == 'asc') { echo ' selected="selected"'; } ?>>Lowest to high</option> </select> </p> <p> <input type="submit" id="book_submit" name="submit" value="Find" /> </p> </form> <?php $books = $page->children($selector); ?> <?php if (count($books)) : ?> <ul> <?php foreach($books as $book) : ?> <li> <p> <a href="<?=$book->url?>"><?=$book->title?></a><br> Publisher: <?=$book->book_publisher?><br> Number of chapters: <?=$book->book_chapters?><br> Number of pages: <?=$book->book_pages?> </p> </li> <?php endforeach ?> </ul> <?php else : ?> <p>No books were found.</p> <?php endif ?> <?php include("./foot.inc"); You might need to change desc/asc values to get them working the way you want.