Jump to content

Wanze

PW-Moderators
  • Posts

    1,116
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Wanze

  1. Your special need is that you want to sort the images of all the galleries by date. This should be possible with the newest version 2.3.0 of Pw So Something like this should work, allthought I've not tested anything: // Load all the images of all galleries, sorted by create date $allImages = new PageArray(); foreach ($pages->find('parent=/albumbs/') as $gal) { $allImages->import($gal->gallery); } // Sort the images by created DESC $allImages->sort('-created'); // get the images you are going to display $items_per_page = 4; $start = ($input->pageNum - 1) * $items_per_page; $total = count($allImages); $images = $allImages->slice($start, $items_per_page); // ... same as in ryans example from here on Does it work? Edit: Don't forget to enable page numbers in the template settings of the template where you are running the code
  2. Hi creativejay, I think you look for something like this: http://processwire.com/talk/topic/390-images-pagination/?p=2928
  3. $pages->find is supposed to return multiple pages. Use $pages->get to get only one page. So when using find, you need to iterate over your pages: $foundPages = $pages->find('template=category'); // Don't use $pages as variable name, it's reserved! foreach ($foundPages as $p) { echo "Found page with title" . $p->title; }
  4. Hi davydhaeyer, welcome! One solution is to create every ingredient as page too and link as many as you want to your recipes. Your page tree would look something like this: - recipes -- recipe1 -- recipe2 ... - ingredients -- ingredient1 -- ingredient2 ... In your recipe template, you can create a Page field (autocomplete) to add ingredients. This way you can add as many ingredients as you want and create them on the fly, if they don't exist: http://processwire.com/videos/selecting-and-adding-pages-with-autocomplete/ (suppose the tags in the video are your ingredients) However, if you need additional data to an ingredient e.g. the number or weight, things get a bit more complex -> Repeater Cheers
  5. This triangle is displayed while the pages are loaded through ajax. Can you open your Javascript console and check for any errors? Also take a look what happens in the network with the ajax request, maybe you have some permission issues.
  6. Hi folks, Running into a problem with OR selectors so I thought to use this thread. Not sure if it's a bug... Problem is the following selector, which does not work: template=product, price|weight='', ... I want products which have no price OR weight entered. However, as soon as one of them has a value, there are no pages returned. If both are empty, it works... Problem is that the resulting query from Pw uses AND instead of OR (marked red): WHERE (pages.templates_id=47) AND (field_weight.pages_id IS NULL OR field_weight.data='') AND (field_price.pages_id IS NULL OR field_price.data='') When testing the selector with a value, it works: template=product, price|weight='test', ... translates to WHERE (pages.templates_id=47) AND (((field_weight.data='test' ) ) OR ((field_price.data='test' ) ) ) No idea if this is easy to fix or a more complicated one... Edit: Submitted an issue on GitHub: https://github.com/ryancramerdesign/ProcessWire/issues/205
  7. Why simpler? When transfering a site locally to the server, I'm always using phpmyadmin. Export all data to a mysql file takes me one minute, importing is just as easy. I think it doesn't matter how you export your stuff - more important is (if there's no other backup running) to do it at all
  8. Looks good to me. I never changed any of the default settings for a simple sql export Cheers
  9. You should describe in more detail what you want to achive, I'm sure you'll get answers here
  10. This looks amazing! Thanks very much
  11. Let's do this. You should be able to read / output your values with something like this: // Loop your plants foreach ($pages->find("template=plant") as $plant) { // selected plant part echo $plant->plant_part->title; // selected products (one or more) if (count($plant->products)) { foreach ($plant->products as $p) { // Title of selected product echo $p->title; } } }
  12. You know that you can define 'allowed template(s) for children' and 'allowed template(s) for parents' in the Family config from your template?
  13. Soma's right. Every Process module extends from the abstract class Process and overwrites the execute method which is hookable. This might not be useful for ProcessPageAdd, but for other modules. In: /wire/core/Process.php /** * Execute this Process and return the output * * @return string * */ public function ___execute() { }
  14. If you want an url structure that is not mapped 1:1 with the pages-hierarchy, you should use url segments: http://processwire.com/api/variables/input/ You need to enable url segments in the template of the pages man/women. When viewing site.com/products/man/brand1/, your first urlSegment contains brand1, so you could filter your products according to that: // In template of men/women... if ($input->urlSegment1) { $brandName = $input->selectorValue($input->urlSegment1); // Get the brand $brand = $pages->get("template=brand, name={$brandName}"); // Brand does not exist, throw 404 if (!$brand->id) throw new Wire404Exeption(); // Brand exists. Get all the products with the brand $products = $page->children("brand={$brand}"); } else { // No url segments... display normal page content e.g. all products under men }
  15. Another way, assuming that you have a 'home' template: if ($page->template == 'home') echo 'Yeah baby, on the homepage!';
  16. If you allow multiple images with your 'logo' field, then the code must work - assuming you have at least one image uploaded on the page viewing. I'd try again If it does not work: Enable debug mode in /site/config.php ($config->debug = true) and check for any errors. Btw when you allow multiple images, why not calling your field 'logos' - would be more logical
  17. Roope, You need to put your sanitized GET vars into the whitelist: $input->whitelist('q', $q);
  18. Hi kalmtl, welcome! 1) Pw can handle > 1000 pages (games) without problems. It scales very well! If you have files/images assigned to your pages, then each page gets a folder where the files are stored. As long as your filesystem / server can handle the files, you won't have any problems. That said, I currently have a project with > 100'000 pages and ~ 1900 Users and everything works fine 2) + 3) Nope. Give your 'game' template the field it needs. Then you can import your old data straightforward with the API. There is also a module by ryan, Import Pages from CSV that maybe useful. If you have relational data separated in different tables, then you could build a similair structure in Pw with Pages, Templates and Page-fields. For Example, store the genres as pages too and in your game-template, create a page field 'genre' that links to a genre-page. Some sample code how easy you can create a new page: $p = new Page(); $p->template = 'game'; $p->parent = $pages->get('games'); $p->title = 'Awesome flash game'; $p->publisher = $pages->get('template=publisher, id=4322'); $p->genre = $pages->get('template=genre, name=action'); $p->year = 2011; $p->save();
  19. Hi einsteinsboi, You can move the blog stuff under its own parent, let's say 'blog' and build a the normal website structure around. Like in this example: In your homepage template, you can include /site/templates/blog.inc. In this file, you find the functions to render the posts, latest comments etc. For example, render the latest 4 comments: $comments = findRecentComments(4); echo renderComments($comments);
  20. Also make sure that your template files are UTF-8 encoded.
  21. You could also use php's trim function to remove whitespaces of a string: echo trim($categories);
  22. Hi Marco, Your field 'img_evento' holds multiple images. To output them, you need another loop: if (count($event->img_evento)) { echo '<ol class="thumb-grid group">'; foreach ($event->img_evento as $image) { echo '<li><a href="#"><img src="'.$image->url.'" alt="'.$image->description.'" /></a></li>'; } echo '</ol>'; You can also create thumbnails inside the loop if your images need to be smaller.
  23. Hi Pascal, The function renderPosts which renders one or multiple posts, takes an argument $small. When small is set to true, the blog profile hides for example the comments and other things. So I suggest that you edit /site/templates/markup/post.php and give your classes based on the $small. $small is true when rendering multiple post and false when rendering one post (detail-view). // 'post-list' class when $small is true, otherwise 'post-detail' $class = ($small) ? 'post-list' : 'post'; echo "<div class='post {$class}'>";
×
×
  • Create New...