Jump to content

diogo

Moderators
  • Posts

    4,314
  • Joined

  • Last visited

  • Days Won

    80

Everything posted by diogo

  1. One more: Loop pages in ProcessWire without building a $pageArray. This is useful for when a find() would return too many results to keep in memory. $selector = "template=pages_template"; // as an example while (1) { $p = wire('pages')->get("{$selector}, id>$id"); // get page with id bigger than previous if(!$id = $p->id) break; // assign current page's id to $id or break the loop if it doesn't exist // do stuff using $p as the current page wire('pages')->uncacheAll(); }; This served me well when I had to modify thousands of pages in one go. Works great with bootstrapping from the terminal because it doesn't affect the viewing of the website.
  2. That depends a lot of how you are structuring your templates. scripts and CSS should go on the head and before the closing body tag, but this has to do more with markup than PW itself. The example on the Owl docs has everything on the head <!-- Important Owl stylesheet --> <link rel="stylesheet" href="owl-carousel/owl.carousel.css"> <!-- Default Theme --> <link rel="stylesheet" href="owl-carousel/owl.theme.css"> <!-- jQuery 1.7+ --> <script src="jquery-1.9.1.min.js"></script> <!-- Include js plugin --> <script src="assets/owl-carousel/owl.carousel.js"></script> Make sure you call jQuery before calling the Owl script, and follow these examples to adapt the css and script links to point to PW templates folder https://github.com/ryancramerdesign/ProcessWire/blob/master/site-beginner/templates/_head.php#L8 https://github.com/ryancramerdesign/ProcessWire/blob/master/site-classic/templates/head.inc#L32 https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/_main.php#L39
  3. You could also iterate all users instead: foreach($users as $u) { if ( $u->hasPermission('page-view', $page) ) // send email to $u->email }
  4. Doesn't seem to me that knowing the previous and next items is necessary to achieve that markup. look at the href of the prev and next links: "portfolio_item1.html#myCarousel". This seems like a link to the project being shown, and whatever the problem is, I bet it is not related to the href of those links. Have a good look at the markup that is being generated by your code (view source in browser) and compare it with the html you just posted to see what's going wrong.
  5. As I thought, you don't need to have the arrows on your markup, they should be added dynamically by Owl, See here http://owlgraphic.com/owlcarousel/#how-to Also notice: You don't seem to be using it in your code.
  6. oh, right... I didn't notice that this code is outside the foreach. Sorry Kongondo. Thinking of it, this carrousel code makes less sense to me. Qurus, can you tell us what carrousel is that one?
  7. So, if the field is correctly set and populated, $page->images is the WireArray and $image the item, no?
  8. If the code is the same as in the first post, they are already. The problem must be another.
  9. Use the getPrev() and getNext() methods: <?php echo $page->images->getPrev($image)->url; ?> -- It's better if you keep $page->images in a variable before the foreach, and call the variable instead of $page->images all the time. $images = $page->images; foreach($images as $image): // and later, inside the href: echo $images->getPrev($image)->url
  10. Just to keep PHP functions out of it $last = $pagearray->pop(); echo $pagearray->implode( ', ', 'title', array('append' => ' & ') ) . $last->title;
  11. Or: $last = $pagearray->pop(); echo $pagearray->implode(', ','title') . ' & ' . $last->title;
  12. Sorry, somehow I didn't link to the plugin above. Edited my post to add it. Anyway, the plugin I was talking about—and forgot to link to—, that is compatible with PF is Lazy load XT. See here about its use with responsive images https://github.com/ressio/lazy-load-xt#responsive-images
  13. Have you considered lazyloading the images? The site takes a long time to load because of them. I did it some time ago on this page that is quite heavy on images, and I think it works quite well. In that case I used this jQuery plugin, but there is a myriad of solutions out there. edit: More recently I also did it in our projects page, that uses picturefill, forgot about that , I used this plugin since it's compatible with PF.
  14. If ($page !== $homepage)
  15. diogo

    other CMSs

    Guys, look at the date of Adam's post. This was even before ProCache was published—not long before, but still before.
  16. You can use iffft https://ifttt.com/recipes/19080-rss-to-facebook
  17. diogo

    other CMSs

    I saw all of those already. It's very interesting the variety of apps that you can do based on such a simple idea. Take a look at some more http://en.wikipedia.org/wiki/Outliner (Moo.do is actually missing there) Feels like doing the same with the pw admin tree, doesn't it?
  18. diogo

    other CMSs

    Revisiting this old thread to feature Fargo. This is a really nice online outliner that can be used also as a CMS. Amazing! Edit: just to put it in context for those that don't know what a outliner is. A outliner is a software that let's you organize info (thoughts, notes, to do's, text, whatever you want) in indented lists. Great examples besides Fargo are WorkFlowy and moo.do. Of course, these don't include a CMS
  19. Soma: * @param id|string|Field $field Field name, id or object
  20. Using the example on that page: $page->getOptions('countries')
  21. Hi there, very nice project Before doing anything, read this tutorial about categorising content in PW by Kongondo https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/ You will understand how much flexibility you gain by storing all data as pages and referencing them with page fields, instead of using simple text fields.
  22. Ya, sorry, I should have read the question better Based on Jan's idea, I think a good approach would be to, for each request callback, add 1 to that global variable on success, and check if the variable is already the total of the requests. If so, fire the function right there.
  23. Taking what you have: function getGeoCodes(jsonFromCsv, callback){ // <- I added the callback parameter WITHOUT parentheses for (var i = json.length - 1; i >= 0; i--) { //AJAX requests and adding the lat / lon to the json object } // After everything is done callback(json); // <- and call it inside the function, just as you had it } // when calling getGeoCodes, you will have to pass the function as a parameter getGeoCodes(yourJson, reformatToCsv) // <- here is where we pass the function, also WITHOUT parentheses PS: I'm not sure what is jsonFromCsv in your case, but here I'm assuming it's some other parameter that you will need and it's not related to the callback function. PS2: I renamed the function inside the other function to "callback" to make it clear that you don't need to use the name of the function there, only while calling it outside. PS3: The reason that I insist so much on having the function without parentheses on the parameters is because the parentheses will cause the function to be called immediately. We want to pass it only as a reference, so we can call it only later inside the function. PS4: by the way @Jan, I didn't comment on your avatar before, but next time make sure you add a custom avatar before it's too late
  24. Actually, I think SVG rocks much more than icon-fonts I can almost bet that they will fade away as soon as there is full SVG inplementation
×
×
  • Create New...