-
Posts
4,314 -
Joined
-
Last visited
-
Days Won
80
Everything posted by diogo
-
That's correct, i changed those later, and maybe you copied them before...
-
you missed the closing brace for the foreach()
-
You can also leave the parent template without a file to throw a 404 when the page is accessed.
-
I would do it maybe like this: foreach ($testimonial as $item) { echo "<div class='testimonial_box"; if($testimonial->getItemKey($item) % 2) { echo " even"; } else { echo " odd"; }; if($item == $testimonial->first()) { echo " first"; }; if($item == $testimonial->last()) { echo " last"; }; echo "'>"; echo $item->body; echo "<p>$item->title</p>; echo "</div><!-- /.testimonial_box -->"; } edit: oh, late again... corrected some quote marks
-
if($item == $testimonial->first()) and if($item == $testimonial->last())
-
I tested the suggestion of Netcarver and it works. On your code, it would look like this: if( 0 == $testimonial->getItemKey($item) % 2) @Netcarver, getItemKey() is on the cheatsheet. Make sure you have the "advanced" checkbox checked
-
In native PHP you can do as Soma said before. But I agree that it would be nice to have this built in the API. Let's wait that Ryan comes back to see what he will say about this
-
How can end-users add gaps/margins in TinyMCE?
diogo replied to onjegolders's topic in General Support
I also have this problem with my users. I think I would prefer that TinyMce would make a break on return and a paragraph on double return -
% is the modulus operator. you can see if a number is even, by checking that it's modulus is zero http://newsourcemedi...d-even-numbers/ and you can also check if a number is odd simply like I did above if( $count % 2 ) because zero is false
-
i wonder if this works... if($p->index % 2) //class odd Edit: so many answers while i was writing this Edit: It doesn't work of course, the code above is trying to find the field named index, and not the index of the page inside an array.
-
You're welcome! I had the same problem recently
-
Ryan already answered to this on another thread. Here it is: http://processwire.c...r-json-support/ (last answer)
-
When pressing the links you get a clean URL? If not I would bet you still have to check the "allow page numbers" on the template like Ryan suggested above.
-
Multiple lists and loops into dynamic reusable piece of code
diogo replied to arjen's topic in General Support
At some point we will have a library of reusable snippets on the website (something like this http://symphony-cms.com/download/xslt-utilities/). I think these kind of things are even better as snippets/functions than as modules, but ya, would also be a nice module -
Discussion/debate over correct or sensible use of repeater fields
diogo replied to Rob's topic in General Support
I think the correct way of using repeaters, is using them, only after deciding that we really can't achieve what we want by the traditional ways. In some situations the pagefield, for instance, will do the same work effectively and even in a more elegant way. I love that we have the repeaters, but i agree we should use them consciously. -
Multiple lists and loops into dynamic reusable piece of code
diogo replied to arjen's topic in General Support
Another edit deserves a new post... I noticed that the previous approach didn't work in some situations where last row wouldn't have any page to populate it (on the first screenshot there is an example with 7 rows and 23 pages). I'm not very good at maths, but I thought that, knowing the mod we could distribute the pages in another way. So, here is the new code with the changes commented: $rows = 7; $totalCount = count($jurisdictionsPageChildren); $rowCount = ceil($totalCount / $rows); $mod = $totalCount % $rows; // this will tell us how many rows will have more pages than the others $firstInRow = 0; $i = 1; while ($i <= $rows){ $mainContent .= "<div class='columns six"; if($i == 1) $mainContent .= " alpha"; if($i == $rows) $mainContent .= " omega"; $mainContent .= "'>"; if($i <= $mod){ // do this when we want one more page on the row $sliced = $jurisdictionsPageChildren->slice($firstInRow, $rowCount); $firstInRow += $rowCount; }else{ // do this when we want one less page on the row $sliced = $jurisdictionsPageChildren->slice($firstInRow, $rowCount-1); $firstInRow += $rowCount-1; } foreach($sliced as $p){ $mainContent .= "<h2><a$class href='{$p->url}' title='{$p->title}'>{$p->title}</a></h2>"; } $mainContent .= "</div>"; $i++; } and on the other screenshots, the working version -
Ryan is on vacations, maybe he will answer only in one week...
-
Multiple lists and loops into dynamic reusable piece of code
diogo replied to arjen's topic in General Support
I don't know how to help you here. But somehow, this should work more or less the same way as pagination does. I wonder if looking into that the module we could find something... EDIT: Ok, this as nothing to do with what i said above. I wrote this code on the browser, and didn't test it. So, take it as a proof of concept. EDIT2: I simplified the code, since the only difference you want is in the class EDIT3: corrected some more code $rows = 4; $totalCount = count($jurisdictionsPageChildren); $rowCount = $totalCount / $rows; $firstInRow = 0; $i = 1; while ($i <= $rows){ $mainContent .= "<div class='columns six"; if($i == 1) $mainContent .= " alpha"; if($i == $rows) $mainContent .= " omega"; $mainContent .= "'>"; $sliced = $jurisdictionsPageChildren->slice($firstInRow, $rowCount); $firstInRow+=$rowCount; foreach($sliced as $p){ $mainContent .= "<h2><a$class href='{$p->url}' title='{$p->title}'>{$p->title}</a></h2>"; } $mainContent .= "</div>"; $i++; } EDIT4: Tested the code above and it's working I had to round up the $roundCount because i wasn't getting the last row with less pages. I used ceil() for that. So, final code would be: $rows = 4; $totalCount = count($jurisdictionsPageChildren); $rowCount = ceil($totalCount / $rows); // <- this is what changed $firstInRow = 0; $i = 1; while ($i <= $rows){ $mainContent .= "<div class='columns six"; if($i == 1) $mainContent .= " alpha"; if($i == $rows) $mainContent .= " omega"; $mainContent .= "'>"; $sliced = $jurisdictionsPageChildren->slice($firstInRow, $rowCount); $firstInRow+=$rowCount; foreach($sliced as $p){ $mainContent .= "<h2><a$class href='{$p->url}' title='{$p->title}'>{$p->title}</a></h2>"; } $mainContent .= "</div>"; $i++; } -
"pages" it's a convenient way of calling well, pages, since they are associated with URLs. But it's best if you forget the word "pages" when developing because it leads you to think of visible website pages, when they really are pieces of content that you can use the ways it suits you better.
-
Congratulations for your first project Not my favorite kind of design because it feels a bit template like. Other than that, it works well and it's well structured. One thing I stumped on: when you go to "Serviços", you have a message "em actualização" that makes people think that there isn't yet any content there, when in reality there is if you press on the links...
-
Hm... can we remove this from showcase? Maybe it doesn't make sense to be there anymore. Arjen, 5 seconds is enough for me
-
It's here http://processwire.c...tsfiles-folder/
-
i googled for "worst sites" in portuguese, and there was a guy saing that the worst site in the world is portuguese and linking to it
-
oh... april fools is over and no one commented on my little joke