Subject for advanced views theming:
1) Create CCK integer field "field_checkbox" - Single on/of checkbox
Allowed values
0|No
1|Yes
2) In views row-style .tpl
<?php print $fields['field_checkbox_value']->content ?>
doesn't print any value, why?
Other fields output fine.
Thank you in advance!
Resolved:
In views settings field output must be unformatted.
Output of above function return 1.
Useful for advanced views theming, for example:
<h3 class="title <?php if ($fields['field_checkbox_value']->content) print 'another-class' ?>">
<?php print $fields['title']->content ?>
</h3>
Related
How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.
I want to get the title called "ABCD" as output from below :
Note I can't use input id to search and have to use classname. Also, note that I have several <div class="promptChoiceListBox" > and class="promptTextField promptTextFieldReadOnly" exist and this is just one example.
Also this Title is dynamic and changed with dropdown selection.
How can I check it in onclick event if the text inside the text is changed?
How can I achieve this ? any help is appreciated.
<div class="promptChoiceListBox" >
<input id="xyz123" type="text" class="promptTextField promptTextFieldReadOnly" readonly="" title="ABCD">
I have tried below and it doesn't work:
console.log($('.promptTextField').attr('title'));
thanks
Javascript way of doing it:
console.log(document.getElementById("xyz123").title);
JQuery (on-click example):
$("input:promptTextField promptTextFieldReadOnly").click(function(){
$("input:promptTextField promptTextFieldReadOnly").toggle();
});
$('.promptTextField').map(x=>x.title)
I have an alert section pulling items with a repeater. My transformation pulls date and copy and displays them in UL tags.
I've been asked to make a change where a specific alert would only be seen by people is a specific group/role.
My thoughts were change the page type form with a check box. On the transformation side i would then need a conditional statement where the check box is true and the user is part of specific Role.
My transformation is currently an ASCX and is as follows:
<li><%# Eval("Alert") %></li>
I imagine it being something like this
<% if ( checked = true && role = XX ) { <li>Eval("Alert")</li> } %>
I just can't figure out the conditional statement.
For Text/XML transformation
{% if(checked == true && CurrentUser.IsInRole("MyRole")) {return "<li>" + Alert + "</li>"} %}
ASCX
<%# If(CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName) && Eval("checked") == true, "<li>" + Eval("Alert") + "</li>","") %>
I'd recommend to add some CSS class based on your condition:
<li class="<% if(Eval<bool>("FieldsName") &&
CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName);) {"alert"} %>">
....
</li>
Having "alert" class added to your li, you can change visibility, colors or whatever you need for that item.
This approach requires ASPX transformation.
You can use the method CurrentUser.IsInRole(, )
I came up with something like:
<%# (checked && CurrentUser.IsInRole("_everyone_", "corporate") ? Eval("DocumentName") : "empty") %>
David
I have a template that is used for entries. The entries have a field that will always have 1 of 2 values. Can I write some PHP to show something different depending on the field value?
Ive tried the following but it gives me a PHP error:
<?php if($my_field == 'value1') { ?>
<h3>Value 1</h3>
<?php } else { ?>
<h3>Value 2</h3>
<?php } ?>
Thanks
You don't have to use PHP.
{if my_field == 'foo'}
Value 1
{if:else}
Value 2
{/if}
If you're planning on doing any EE tag processing within those conditionals, you shouldn't use the if:else syntax, as with it, the content between the conditionals will always be parsed, but just not displayed, which needlessly uses server resources and increases load time.
So in that case, use simple conditionals instead:
{if my_field == 'foo'}
Value 1
{/if}
{if my_field == 'bar'}
Value 2
{/if}
See: http://expressionengine.com/user_guide/templates/globals/conditionals.html
You can use ExpressionEngine's Conditional Global Variables to display your content, without having to use PHP in your templates.
Rewriting your example using native ExpressionEngine's Simple Conditional tags would result in the following:
{exp:channel:entries channel="channel_name" dynamic="off"}
{if "my_field" == "value1"}
Value 1
{/if}
{if "my_field" == "value2"}
Value 2
{/if}
{/exp:channel:entries}
You can use simple or complex conditionals anywhere in your templates, with the former being less resource expensive, but ExpressionEngine's Parse Order (PDF, 32 KB) may affect how they're evaluated and replaced.
In most cases, you'll need to ensure your custom fields and conditionals are within the {exp:channel:entries} tag loop for the values to be properly output and tested when the page is being built.
I'm a total newbie and want to start with php. I know some javascript already.
I want to be able to type some text in a form and convert it to a query e.g.
In my website there's this search box, I type in 'example' click submit and it gives me this=
http://www.externalsite.com/search?s=example&x=0
and pastes it to the address bar, you know like a search engine.
Any guidance will be appreciated.
Well, as you are doing PHP, you should point your form to submit to a PHP file. Then to retrieve the data, use $_GET or $_POST depending your form is posting or getting (as I can see from your exemple its a GET) so something like this :
HTML :
<form method="get" action="search.php">
<input type="text" name="q" id="q" value="" />
<input type="submit" value="Submit" />
</form>
On the PHP side :
<?php
$query = $_GET['q'];
header('Location: google.com/search?q=' . $query . '%20term');
die();
?>
Basically you're typing your search term into a form, which then posts (via GET) to a search page, which queries its database for records matching that string. A simple example of this follows:
index.php
<form method="get" action="search.php">
<p><input type="text" name="terms" /></p>
<p><input type="submit" value="Search" /></p>
</form>
When you submit that, it will direct you to search.php?terms=[terms here]. Our code found within search.php follows:
search.php
mysql_connect($host, $user, $pass) or die(mysql_error());
$terms = $_GET["terms"]; // you'll want to sanitize this data before using
$query = "SELECT col1, col2, col3
FROM tablename
WHERE col1 LIKE '%{$terms}%'";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
print "We've found results.";
} else {
print "No results found.";
}
This is a very simple example (don't copy/paste this into production). Essentially you're pulling the submitted value(s) into a query, and then showing any results. This should be enough to get you started, but feel free to visit us here if/when you have more specific questions in the future.
Best of luck!