Display all categories but one in expression engine - expressionengine

My code is below I want to display all my categories except one that I want to link directly too. category_id_not doesn't seem to work.
{exp:channel:categories category_group="4" style="linear" show_empty="yes" category_id_not="42"}
<option value="/events/category/{category_url_title}">{category_name}</option>
{/exp:channel:categories}

{exp:channel:categories category_group="4" style="linear" show_empty="yes" show="not 42"}
<option value="/events/category/{category_url_title}">{category_name}</option>
{/exp:channel:categories}
category_id_not is not a valid parameter, nor is category_id (although that would be consistent and logical) you should use show="not 42" instead.
Full docs here.

Related

How can I figure out which chapter is "selected" value using web scraping with python. I want to get the selected and get the chapter and volume

I have this html that I am trying to scrape off a website
<select class="navi-change-chapter">
<option data-c="24">Vol.4 Chapter 24</option>
<option data-c="23" selected>Vol.4 Chapter 23</option>
<option data-c="22">Vol.4 Chapter 22</option>
<option data-c="21">Vol.4 Chapter 21</option>
<option data-c="20">Vol.4 Chapter 20</option>
<option data-c="19">Vol.3 Chapter 19</option>
<option data-c="18">Vol.3 Chapter 18</option>
<option data-c="17">Vol.3 Chapter 17</option>
I want to be able to scrape the selected value and from that value I want the volume number and the chapter number
You may need to edit this as I can only go off the HTML provided:
# Get the <select> element. I use Tag Name for brevity.
dropdown = driver.find_element(By.TAG_NAME, "select")
# Use a CSS Selector to find the option with the 'selected' attribute.
selected = dropdown.find_element(By.CSS_SELECTOR, "option[selected]")
print(selected.text)
This prints Vol.4 Chapter 23. You can then splice the text to get the information you want. You can get the chapter from the data-c attribute with:
selected.get_attribute("data-c")
Using the sample data, this returns 23.

Materialize - Change select option text with js / jquery

I'm using Materialize and try to change the options's text via js/jquery for multilingual use.
<select>
<option value="" disabled selected data-translation="languageselect"></option>
<option values="en-GB">English (en-GB)</option>
<option values="de">Deutsch (de)</option>
</select>
I translate all objects containing the data-translation attribute via JS (using innerHTML).
So the translation script is something like (and it works)
translationObject.innerHTML = translation
But now I'm using Materialize and have a problem with the options texts. The translated text is not displayed - first I call my translation function and then the initialization of the select element.
$('select').formSelect();
Anyone an idea?

selecting options in spectron test

I am developing an desktop application using Electron and NodeJS, what it specifically is isn't really important. I am using spectron to test my electron application. I have implemented a functionality for selecting between different saved databases through a dropdown list with options. When a database is selected in the dropdown, a json file with login credentials is updated to match the selected db. I want to write a test that checks that the json file is changed when another option is selected. My main problem is to simulate the selection of another option from a dropdown menu.
// Psuedo code for what how I want to solve this
it("DB connection file is updated correctly", function() {
read in json file with currently selected db credentials as a "before reference".
simulate the selection of another db in the dropdown list so that json file from before is changed.
read in changed json file
assert.notDeepEqual(beforeFile, updatedFile);
});
The thing I have been stuck on is the part where I have to select another option in the dropdown to change current DB. I have read on the spectron docs and also on webdriverIO docs but I still cant get it to work.
There will always be 3 default databases listed as options in the dropdown menu. I'll list the html code for the dropdown under:
<div id="list-container">
<form>
<label id="dropdown-label" for="connection-dropdown"><b>Database</b>:</label>
<fieldset id="dropdown-fset">
<select name="database" id="connection-dropdown">
</select>
</fieldset>
</form>
</div>
Been stuck for over a week now and I cant find any way to solve it online either. A lot of questions how to do stuff with spectron but there was no answers that helped me this time. I have probably forgot to mention something so please ask if more info is needed.
Thanks!
You are able to collect elements, you can collect "select" elements under #list-container after that you can use these elements.
The thing I have been stuck on is the part where I have to select
another option in the dropdown to change current DB
I don't see any actual option elements in your HTML but if you are going to have something like this:
<select name="database" id="connection-dropdown">
<option value="someValue0">uno</option>
<option value="someValue1">dos</option>
<option value="someValue2">tres</option>
<option value="someValue3">cuatro</option>
<option value="someValue4">cinco</option>
<option value="someValue5">seis</option>
</select>
Then you can apply the one of several option commands. One of these is selectByVisibleText(). That link has a nice example. Place this setup in a beforeAll().

Firewatir: Problems changing selection in select list

I'm new to FireWatir and having some issues changing a selection in a select list. Here's what the HTML looks like:
<div id="softwarelist">
<select name="TDSOFTWARE" style='width:191;'>
<option value="QFX">Quicken 2004 or newer-Windows
<option value="QIF">Quicken 2003 or older-Windows
<option value="OFX">Microsoft Money 98 or newer
<option value="QIF">Microsoft Money 97 or older
<option value="CSV">Microsoft Excel
</select>
</div>
I need to change the selection to CSV.
Here's the line in my script where I am stuck:
browser.div(:id, "softwarelist")
I've sort of randomly tried various methods, but (obviously) none have worked. Using the method 'show_all_objects', like so:
puts browser.div(:id, "softwarelist").show_all_objects
I get a list of all the various formats... that leads me to believe I am in the right ballpark at least, but really I have no idea as I am new to working with FireWatir.
Can anyone point me in the right direction?
Something like this should work (not tested):
browser.select_list(:name, "TDSOFTWARE").set("Microsoft Excel")
For more information take a look at Selection Boxes page at Watir Wiki.
Your problem is that you are trying to treat the div, which contains the selection list, as if it was the selection list. So you are trying to manipulate the wrong object. you are 'close' because that's the outer container around the list, so show_all_objects will report on the list, which is inside that div.
the code in Zeljko's answer ought to work for you.

Google chrome dropdown list options ordering seems to be incorrect

I am using the following code for rendering a select box in one of my form and when i inspects i can see the following code in Firefox
<select name="make">
<option value="13501">Jeep</option>
<option value="26838">Joyner</option>
<option value="13658">Kia</option>
<option value="13898">Lada</option>
</select>
But in chrome when i inspect the form element i can see
<select name="make">
<option value="13501">Jeep</option>
<option value="13658">Kia</option>
<option value="13898">Lada</option>
<option value="26838">Joyner</option>
</select>
Any one please suggest a solution for this?
It's not a real good practice but...
If you add a space to the value chrome will not consider value a number and won't sort them by value.
Example:
<select>
<option value=" 3">Third</option>
<option value=" 1">First</option>
<option value=" 2">Second</option>
</select>
The good side is that you have not to add and then remove alphabetic characters from ID like someone suggested (don't remember if in this or other post with similar question), you could easily trim it but most of the times the space is just ignored and if you post or get those to another file they will simply see the integer value not the space.
This happens to me too. With the following client side JS:
var data=incoming_json_assoc_array_of_counties_sorted_alphabetically_by_county //eg 47=>"west midlands"
for (key in data) {
options.push('<option value="' + key + '">' + data[key]+ '</option>');
}
$('#county_id').val(options.join(''));
It seems like chrome will not support integers as property names or will sort by the key rather than the value. Irrespective of the value that the data comes in
This is a pain in the backside as most of my arrays are num=>data assoc arrays.
Please visit http://code.google.com/p/chromium/issues/detail?id=12169 for an explanation, still looking for a workaround/fix.
This doesn't do it in FF or even safari which is webkit based.
Tried on PC and MAC chrome and get the same problem.
The other option I suppose is to render the HTML on the serverside and just use your JS to plonk the data into the .. tags as opposed to generating it client side.
[update]
see Google Chrome: JavaScript associative arrays, evaluated out of sequence for good solid answer
[edit 2013]
Apperently this still hasn't been fixed It's valid behaviour according to ECMAScript standards but it's not how one would 'expect' it to behave. Have you though of using chosen.js which could help you get around the problem.

Resources