Joomla JView::get() two parameters - joomla

Well, i have a question and i am so confused that i decided to ask you.
What do these statements show?
Does this display the value? (the value property of option element OR the text(JHIDE or JSHOW))?
$this->params->get( 'show_title');
And what does this statement with the two parameters indicate?
$this->params->get( 'show_title', 'JHIDE');
Could it be written in another way?
Here is the XML part of this statement:
<field name="show_title" type="list" default="" label="SHOW_ARTICLE_TITLE"
description="SHOW_ARTICLE_TITLE_DESCR">
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="">USE_GLOBAL</option>
</field>
I am very confused and i cant find the answer, even though i have printed their values with var_dump, print_r, echo etc.
Thanks in advance!

show_title displays the value from the option that is selected.
'JHIDE' which is the second parameter, defines the default.
The default doesn't technically have to be defined but it's best to do so. It should not always be written any other way as it's a simple method that Joomla coding standards.

Related

Cypress: How do I get the text of the selected option in a select drop-down list?

I want to be able to get the text of the selected option and not the value. I would use the value but Angular is changing it and putting the value in a ng-reflect-ng-value attribute.
<option _ngcontent-c1="" value="5: 1" ng-reflect-ng-value="1">Miscellaenous</option>
This will work, but I want to check that it equals "Miscellaenous"
cy.get('#id-9999').find('.categoryList').should('have.value','Miscellaenous');
This worked for me:
cy.get('#id-9999').find('.categoryList').find(':selected').contains('Miscellaenous')
This is how it should be done:
cy.get('#id-9999').find('option:selected').should('have.text', 'Miscellaenous');
Among other things, it checks for the exact match and not for a substring (like in your solution).
We've found that chaining find() off get() sometimes breaks our tests, so we use this other way:
cy.get("#my-select-element option:selected")
.should("have.value", 3);
as opposed to:
cy.get("#my-select-element")
.find("selected")
.should("have.value", 3);
When using Cypress I found that :selected did not work, however :checked did work. So to modify one of the other answers here, this works (at least for me):
cy.get("#my-select-element option:checked")
.should("have.value", 3);

How do I select an item from a drop down with Site Prism?

I have the following elements defined within a SitePrism page:
element :type, "select[id='type']"
elements :type_options, "select[id='type'] option"
And in my cucumber step definitions I have the following code to select an item from the select box based on the elements value:
#app.new.type_options.each {|name| name.click if name.text.upcase == value.upcase}
I don't really like this implementation but it does work perfectly when running Capybara in chrome but fails when I run it headless so I figure there must be an alternate / better way to select drop down items.
Ideally I'd like to be able to do something like #app.new_r.r_type.select 'value', but I can't work out how to do this in SitePrism.
So, my first question is, can anyone recommend an elegant way to select an item from a drop down based on value from SitePrism?
And my second question is, any idea why the above code fails when running headless?
I had a similar problem, where I couldn't get it to select the option I wanted. I came across this question and it made me realize my problem was that you have to send the text, not the value, to the select().
For example, if I have HTML like
<select id="things">
<option value="thing1">The First Thing</option>
<option value="thing2">The Second Thing</option>
<option value="thing3">The Third Thing</option>
</select>
And in my SitePrism::Page class I have:
element :things, "select[id='things']"
I thought I needed to do:
#my_page.things.select("thing1")
That does not work. Instead you have to do:
#my_page.things.select("The First Thing")
I know this is slightly different than trying to select based on a value you get from SitePrism, like was originally asked. But I thought this distinction about what to pass to select() might help someone.

XPath greater than operator?

I'm trying to select all event log entries beyond a certain date. So far I think I got equals, but I don't know how to change this to greater than the specified date... so close yet so far!
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[TimeCreated[#SystemTime='2013-01-01T12:21:25.0000000']]]</Select>
</Query>
</QueryList>
I found the best way to create a XPath query for EventLog. See here on how to create a custom view. After you create the custom view, with whatever filter you want, simply click on the XML, and voila, it shows you the XPath query that it constructed itself!
The next challenge was the formating of the date. I used this: "yyyy-MM-ddThh:mm:ss:fffZ"
I also think you cannot create a filter that says, shows me everything after this date. So I simply recreated a range between the date I wanted and the current date.
For completeness, here is the filter that I created (who dreams up specs for this?)
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[(Level=1 or Level 2 or Level=3) and TimeCreated[#SystemTime>='2013-01-01T12:00:00:000Z' and #SystemTime<='2013-02-13T05:30:34:948Z']]]</Select>
</Query>
</QueryList>
Use something like this:
*[System[TimeCreated[
number(translate(substring-before(#SystemTime, 'T'), '-', '')) > 20130101]]]
If you need to consider the entire string, then strip everything unnecessary to the comparison:
*[System[TimeCreated[
number(translate(#SystemTime, '-T:.', '')) > 201301011221250000000]]]

Codeigniter calculate day, week, month, year from search

I am developing a job site, and the custumer would like the following.
On the job submit, the user will be able to set a date when the actual job will start, and in the search there are the following options for job start to select:
<option value="">Today</option>
<option value="">Tomorrow</option>
<option value="">In a week</option>
<option value="">In a month</option>
And im a bit lost at this part, i never did something like this.
Now i dont want anybody to write this for me, just give me an advice or a hint, for the logic, if its posible.
What i donr really get is, what values should i give the options, and how to get the actual reasults if there is.
Thank you
The values only need to be ones you'll recognize when processing the request. They could be "today", "tomorrow", "next_week" and "next_month" if you want.
Then when handling the request, take today's date and add:
nothing (today)
one day (tomorrow)
seven days (in a week)
one month (in a month)
Look at DateTime::add for the date arithmetic part.
I would like to add one thing only.
Replace the value attribute of Option tag. For example
Today
Then handle the request through server. This is very nice logic to implement and its rather easy.

Ordering $file by name - Smart templates

I wonder if anyone can help me. I'm using PodHawk - a basic podcast cms, I would like the admin area file select to show my files in order - by name.
The select/option dropdown uses this code, is there a straightforward way to get the dropdown to display in order by name,. I've searched but cant find anything in the Smarty documentation, but I'm probably using the wrong terminology!
{foreach from=$upload item=file}
<option value="{$file|escape:'url'}">{$file}</option>
{/foreach}
many thanks rob
Solved with many thanks to poster below -
{$upload|#sort:$smarty.const.SORT_NUMERIC}
{foreach from=$upload item=file}
<option value="{$file|escape:'url'}">{$file}</option>
{/foreach}
cgwyllie neglected that asort() returns a boolean, not the sorted array. So his approach wouldn't work. As the index is not used, a(ssociative)sort is not required.
{$_foo = $upload|sort:$smarty.const.SORT_LOCALE_STRING}
{foreach $upload as $file}
<option value="{$file|escape:'url'}">{$file|escape:"html"}</option>
{/foreach}
should do the trick. Make sure you really need that $file urlencoded, otherwise change escape:"url" to escape:"html".
(the above is Smarty3 syntax)
If the variable $upload contains an array of file names, then it should be possible to apply the PHP asort function (http://php.net/asort) to the array as a smarty modifier.
{foreach from=$upload|#asort item=file}
<option value="{$file|escape:'url'}">{$file}</option>
{/foreach}
The # symbol is needed to apply the modifier to the array as a whole, and not to each individual element. (See http://www.smarty.net/docsv2/en/language.modifiers.tpl)
If the array is of more complex data structures than just strings, the following discussion may be of use to you: http://www.smarty.net/forums/viewtopic.php?t=1079&postdays=0&postorder=asc&start=0
Edit
As mentioned by rodneyrehm, this solution is not quite correct although the poster found a satisfactory solution at: http://www.smarty.net/forums/viewtopic.php?t=1079&postdays=0&postorder=asc&start=0

Resources