I have some code that creates a table that alternates row colors based on the row value of the entry.
<table class="authorList" cellspacing="0">
{exp:channel:entries channel="team" disable="categories|member_data|pagination" orderby="team-last-name" sort="asc"}
{if team-not-with-us != 'y'}
<tr class="{switch="odd|even"} authorInfo">
<th class="authorName">
{if team-bio != ''}<a href="{site_url}about/the-team/{url_title}">{/if}
{title}
{if team-bio != ''}</a>{/if}
</th>
<td class="position">{team-position}</td>
</tr>
{/if}
{/exp:channel:entries}
</table>
The problem is when I delete an entry, I end up having two odd or two even numbers in a row, leaving me with two like-colored rows side by side.
While the switch function is convenient, it is referencing the row count within the database. I don't believe I can apply it to reference the actual row count in the if statement which would solve my problem. (Correct me if I'm wrong.)
I know how to make this change with php:
<?php $oddevenrow = 0; ?>
{if team-not-with-us != 'y'}
<?php $oddevenrow++; ?>
<?php ($oddeven = ($oddevenrow % 2 ? 'odd' : 'even')); ?>
<tr class="<?php echo $oddeven; ?> authorInfo">
But I'm not allowed to turn PHP on in the EE install.
Is there something similar I can do in EE?
Thanks!
You're looking for the switch tag.
{switch="odd|even"}
But it looks like you already knew that. It looks like you're requiring the variable team-not-with-us to != 'y'. Because you're doing that validation after results have been returned you'll end of with multiple odd or even rows next to each other. The easy way to avoid this is to use the channel:entries search param. Example: search:team-not-with-us="not y"
<table class="authorList" cellspacing="0">
{exp:channel:entries
channel="team"
disable="categories|member_data|pagination"
orderby="team-last-name"
sort="asc"
search:team-not-with-us="not y"
}
<tr class="{switch="odd|even"} authorInfo">
<th class="authorName">
{if team-bio != ''}<a href="{site_url}about/the-team/{url_title}">{/if}
{title}
{if team-bio != ''}</a>{/if}
</th>
<td class="position">{team-position}</td>
</tr>
{/exp:channel:entries}
</table>
You might want to try asking the EE peeps at https://expressionengine.stackexchange.com/ The {count} tag should work. That simply counts every entry that (in your case) is in the Team Channel and is not Y in your "team-not-with-us" field group, which I'm assuming is a switch or a select box or something.
What does your outputted code look like?
Related
I want to set my tr class to bg-success when the status is equals 'EXECUTED'. Here is my code:
<th:block th:switch="${order.status}">
<tr th:case="'EXECUTED'" class="bg-success">
<tr th:case="*" class="bg-warning">
<td>...</td>
</tr>
</th:block>
It's obvious that I append two tr rows and don't close the first one, but in reality it's just one appended.
One solution is to rewrite the <td>...</td> in every case but it's a poor one. Is there any better solution without rewriting the <td>..</td> or using javascript?
Hope this helps :
<tr th:class="${order.status.equals('EXECUTED') ? 'bg-success' : 'bg-warning'}">
<td>...</td>
</tr>
Using xpages on domino 8.5.3 server.
Can a djcheckbox be use with muiltiple value field similar to a checkboxgroup ?
if so, would it be possible to supply a code snippet.
Thanks
dijit.form.CheckBox can deal with only one value and that's true for djCheckBox too as it's based on dijit.form.CheckBox.
You could combine several djCheckBox controls and let it look like a checkBoxGroup. Bind every djCheckBox to a viewScope variable initialized by a document item and write values back at document save.
Here is an example for UI similarity to checkBoxGroup:
<fieldset
class="xspCheckBox">
<table>
<tbody>
<tr>
<td>
<xe:djCheckBox
label="abcdefg"
id="djCheckBox4"
value="#{viewScope.abcdefg}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="hijklmno"
id="djCheckBox5"
value="#{viewScope.hijklmno}">
</xe:djCheckBox>
</td>
<td>
<xe:djCheckBox
label="pqrstuvwxyz"
id="djCheckBox6"
value="#{viewScope.pqrstuvwxyz}">
</xe:djCheckBox>
</td>
</tr>
</tbody>
</table>
</fieldset>
I am not sure though what's the reason for your question and if it's worth the extra effort.
I have a table like this:
Table
<!DOCTYPE html>
<html>
<body>
<table border="1" style="width:100%">
<tr>
<td>email</td>
<td>data</td>
</tr>
<tr>
<td>creator_a#creator.com</td>
<td>"vimeo_profile"=>"", "twitter_profile"=>"", "youtube_profile"=>"", "creator_category"=>"production_company", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "instagram_profile"=>"", "content_expertise_categories"=>"4,5,8"</td>
</tr>
<tr>
<td>creator_b#creator.com</td>
<td>"twitter_profile"=>"", "creator_category"=>"association", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "content_expertise_type"=>"image", "content_expertise_categories"=>"4, 6"</td>
</tr>
</table>
</body>
</html>
And I want to query this using PostgreSQL, so I only get the values regarding content_expertise_categories:
*Important to mention that the number of values vary. The table has many more entries so I am looking for a solution that helps me extract the values regardless of whether there are 2 or 15 values to pull out.
Result
<!DOCTYPE html>
<html>
<body>
<table border="1" style="width:100%">
<tr>
<td>email</td>
<td>data</td>
</tr>
<tr>
<td>creator_a#creator.com</td>
<td>4,5,8</td>
</tr>
<tr>
<td>creator_b#creator.com</td>
<td>4,6</td>
</tr>
</table>
</body>
</html>
I have tried substring but can't make it to work.
Some help would be much appreciated, thanks!
SELECT
email,
(string_to_array(
data::text,'"content_expertise_categories"=>'::text
)
)[2] as data
FROM users
;
Update:
In your example all strings have "content_expertise_categories" listed last, which allows to think you can just split string to two pieces. If you happen to have more php array definition values after, you'll need an additional split on ',"' and taking [1] part this time...
Mind casting column "data" to ::text before using it in content_expertise_categories function, as it requires text type, and your column appeared to be not such.
I believe more elegant would be this query:
select
email,
data->'content_expertise_categories' as data
from h
;
But when I was posting first query I did not know that you use hstore
I have a tableview and I want to show an image in the first column. My problem is I can't sort the column then. My idea is to set text in the column too and hide the text so it is only for the correct sorting set. Is there a way to do that? Or what other solutions are possible for my problem?
I think this is the perfect example what you wants to do.Still let me know if you have any issue.
Check here
I would have a look at TableColumn.setCellValueFactory() and TableColumn.setCellFactory(). The further is used to provide the actual cell value (used for sorting!), the latter is used to provide the rendering.
In other words: If you need the sort order, you must not change the content, but only the Cell rendering. The methods mentioned above let you do exactly this.
Hope that helps ...
You could do it with just CSS using text-indent. You would also need to set the image as a css background. You did not provide an code of your table, but below is some example:
HTML:
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td class="hidetext image">Text 1</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 2</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 3</td>
<td>Some text to show</td>
</tr>
<tr>
<td class="hidetext image">Text 4</td>
<td>Some text to show</td>
</tr>
</table>
CSS:
.hidetext {text-indent:-9000px}
.image {background:url(http://www.madisoncopy.com/images/jpeg.jpg) no-repeat;}
See how in the left column the text does not show (but it is actually there just indented off the screen).
See this fiddle: http://jsfiddle.net/D297P/
I want to display up to 200 words of the related results just in the next line to title
But i am not getting the text that {excerpt} should Display
My code is written below
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
<table border="0" cellpadding="6" cellspacing="1" width="100%">
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
<tr class="{switch}">
{if page_meta_title != ""} <td width="30%" valign="top"><b>{title}</b></td>{/if}
</tr>
<tr><td style="color:red!important">{excerpt}</td></tr>
{if count == total_results}
</table>
{/if}
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{/exp:search:search_results}
</table>
Maybe this was just a typo in your question, but it looks like you have the opening search tag listed twice.
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
<table border="0" cellpadding="6" cellspacing="1" width="100%">
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
Also, the excerpt tag by default allows 50 characters. You can also consider the character limiter plugin (http://devot-ee.com/add-ons/character-limiter) which is a free plugin from Ellis Lab. Once you have that setup, you would use it like so....
{exp:char_limit total="200" exact="no"}{your_text_field}{/exp:char_limit}