Hot answers tagged

10

You should put the closing </row> outside your channel entries tag, to be consistent, and use a switch statement to add the middle rows every third entry: <div class="row"> {exp:channel:entries channel="channel_name" dynamic="no"} <div class="span4"> ... </div> {switch='||</div><div ...


7

Much simpler than you think! Just add url_title="not '{segment_3}'" to your Channel Entries tag. (Or whichever segment holds your entry's url_title.)


6

It looks like you found a bug, Sean, sorry you got bitten by it. I've reported it and posted a fix here: https://support.ellislab.com/bugs/detail/19871


5

The GWcode Alternate addon will accomplish what you need. This simple plugin for ExpressionEngine 1 and 2 lets you rotate through any number of values to create alternations, for CSS classes for example. You can use this plugin to rotate through any number of values, similar to the switch variable in the {exp:channel:entries} tag for example. ...


4

I too might go for the {switch} method. But I would also question if using Bootstrap's CSS classes are the best way to mark up your page. Have you considered using their LESS classes? You could then possibly keep your EE and HTML as separated from the design as this... <section id="section-name"> {exp:channel:entries channel="channel_name" ...


4

It's a common task to want r rows of x items, and I've sometimes got myself tangled with switch and conditionals etc still finding I end up with empty or unclosed tags. I find the EEGrouper add-on http://devot-ee.com/add-ons/eegrouper is a quick and easy way to handle all cases.


4

I managed to find a simple solution as I wrote the question. This just uses a combination of {switch} and a {if count != total_results} conditional: <div class="row"> {exp:channel:entries channel="channel_name" dynamic="no"} <div class="span4"> ... </div> {if count != total_results} {switch='|</div><!-- /row --> ...


4

I’ve found the solution: {switch='odd|even'} needs to be namespaced so that it switches within the context of the relationship field, like so: {staff_member_groups:staff_group_members:switch='odd|even'} Otherwise, {switch='odd|even'} is going by the larger context of the entries tag that surrounds this template. For clarity, my final block of code looks ...


4

Well, if you want a modulus operator, use a modulus operator! {if total_results % 2 != 0} </div> {/if} Maybe you can find it easier this way: {exp:channel:entries channel="bullets" dynamic="no"} {if count = 1 OR count % 2 == 1} <div class="bullets"> {/if} <div class="col-lg-6 col-sm-6"> ...


3

I see this has already been answered, but there is a jQuery option that might be better for you. At least it won't matter how many categories there are: $('.selector:nth-child(3n)').after($('<div />').addClass('clearfix')); This will select every 3rd element that matches .selector and insert <div class="clearfix"></div> after it.


3

Looks like I got it working. maybe this will help someone else out, or maybe someone will find an even better solution. I simply switched {if row_count != total_rows} & {if row_count == total_rows} to {if count != total_results} & {if count == total_results} so the final code in my template is: {playa_field show_future_entries="yes" ...


3

I'd likely just do it with a channel entries loop - if only to take advantage of native publish and expiry date functionality so the client can schedule the publishing and hiding of the link you're referring to with ease, particularly if there is any changing content within the feature you're describing (which could then be handled on an entry by entry basis)...


3

If you're wanting the switch tag to apply to the grid rows, then you need to prefix it with your grid field name (docs): {press_releases:switch='|||</div><div class="row">'}


3

You can capture the entries as a Stash list and use fractions to split into parts: Setting the list: https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Aset_list%7D#capturing-channel-entry-data Getting the list and using fractions: https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Aget_list%7D#using-fractions-to-split-lists


3

I'd like to add that with the Modulus Operator added to EE in 2.7.1 that this can be easily achived now with the following code, based on Bootstrap 3 (example using a Grid fieldtype for the output): <div class="container"> <div class="row"> {gallery} {if gallery:index % 3 == 0 OR gallery:index != 0} </div> ...


3

My approach to handling this issue is to use the SurgerEE addon which provides (among many other useful things) modulo operator support via a plugin call, so you can then do something like this: <div class="row"> {exp:channel:entries channel="channel_name" dynamic="no"} <div class="span4"> ... </div> {if '{exp:surgeree:modulo ...


2

surely on a listing of entries you should have dynamic="no" set, like so: {exp:channel:entries dynamic="no" limit="2" channel="ministries" {gv_param_disable_default}}


2

Fieldpack 2.02 fixed this problem.


2

I’ve accepted Jean’s answer above, but wanted to document my own solution. Because this particular case involved querying a single-entry channel, I simply used the status field of the entry to “turn the page on or off”, as it were. Any status that is not Open (that is, Draft or Closed) will yield zero results in my loop, so I use a no_results conditional to ...


2

Yes you could use switch also. {exp:channel:entries} <div class="wrap {switch='col-lg-4|col-lg-8'} col-sm-12 content-item"> ... </div> {/exp:channel:entries} Would output alternating containers with the correct col-lg class: <div class="wrap col-lg-4 col-sm-12 content-item"> ... </div> <div class="wrap col-lg-8 col-sm-...


1

If I follow your question correctly, the output you want is for each pair of entries to be in their own sections, with the sections alternating between white and light grey backgrounds. I'm not sure about this, because your sample code appears to list all the entries within a single pair of <section> tags. If your output does split pairs of entries ...


1

WOW! I'm an idiot. lol I read right past the lists in the docs. Thanks for a great add on and doc set Mark. ;) https://github.com/croxton/Stash/wiki/Lists {exp:stash:set_list name="mini_links" parse_tags="yes"} {mini_links} {stash:href}{mini_links:link}{/stash:href} {stash:text}{mini_links:title}{/stash:text} {/mini_links} {/exp:...


1

You'll want to upgrade Fieldpack to 2.1.1 (make sure to read installation notes!)


1

Matrix field has his own {switch} tag, so channel {switch} tag (is it what you mean by "native switch function" ?) will be not working inside Matrix pair.


1

That's because of your index.php isn't included in your language changer link. http://kanuk.com/dev/index.php/Collection/femmes/manteaux-chauds goes to: http://kanuk.com/dev/fr/Collection/femmes/manteaux-chauds which is missing the index.php element: http://kanuk.com/dev/fr/index.php/Collection/femmes/manteaux-chauds/ Either modify your htaccess so it ...


1

OK, I'll kick this one off... Firstly you will need a trigger to tell the site you're dead. How to do this is the hardest part! Possibly you have to log in once a week to verify, but ultimately you'll need some failsafe's in place otherwise you risk worrying friends and relatives with your premature news. Either a Extension utilising a Session hook that ...


1

Try something like this. You'll see that pt_switch actually outputs 'y' not 'yes'. :) If you're having trouble with conditionals. always echo out your variables so you can see what you need to test against. :) {exp:channel:entries channel="pt_test_channel"} <h1>{title}</h1> {pt_switch} {if pt_switch == 'y'} yessirreebob {/...


1

If you know the exact number of categories that will be displayed, you can use conditionals in combination with the {count} variable.


1

You have a limit=1 set on the entries tag. So there is only 1 iteration in the loop. For the switch tag to work, it needs to have more than one entry to rotate through the values. Setting the limit to 2 or higher will work.


1

This can probably be done on the CSS side of things also. Just set the class to something to identify the channel and use nth-child(3n+0) to style them differently. http://www.w3schools.com/cssref/sel_nth-child.asp


Only top voted, non community-wiki answers of a minimum length are eligible