Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Filtering categories based on the chosen section (back end)
a7aylor wrote #279690:
Amateur plugin question (current experience is paste and click upload :-) – How do I get your PHP code as a BASE64-encoded piece of text to paste in on the plugin page?
Plugin Composer is the easiest option.
Offline
#17 2014-03-12 15:08:04
- a7aylor
- New Member
- From: Manchester, UK
- Registered: 2014-03-11
- Posts: 9
Re: Filtering categories based on the chosen section (back end)
Bloke wrote #279688:
Try
.val()instead of.text(). Unless your section titles exactly match your category names, they won’t match. That’s what the plugin I posted above does and it works.
No joy. The match is with the names, not the titles.
Offline
Re: Filtering categories based on the chosen section (back end)
a7aylor wrote #279692:
No joy. The match is with the names, not the titles.
Hmm. Take a look at the page’s HTML source code and check the <option> value attributes. The aim is to match the category with the section somehow, bearing in mind Txp will sanitize both section and catgeory titles because they form part of the URL. So, for example, “Human Sciences” would become “human-sciences” in both cases.
The .val() gets the option value names whereas .text() gets the (screen-visible) title of the option so you may need to mix and match them to get the desired outcome depending on how you’ve set them up.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#19 2014-03-12 15:35:40
- a7aylor
- New Member
- From: Manchester, UK
- Registered: 2014-03-11
- Posts: 9
Re: Filtering categories based on the chosen section (back end)
Ok so, heres the sections…
<option value="biology">biology</option>
<option value="chemistry">chemistry</option>
<option value="french">french</option>
<option value="ict">ict</option>
<option value="inclusion">inclusion</option>
<option value="physics">physics</option>
<option value="spanish">spanish</option>
<option value="test">test</option>
Heres are some of the categories…
<option value="biology">Biology</option>
<option value="b1">  B1</option>
<option value="b2">  B2</option>
<option value="b3">  B3</option>
<option value="biology-keywords">  Keywords</option>
<option value="isa">  ISA</option>
<option value="chemistry">Chemistry</option>
<option value="c1">  C1</option>
<option value="c2">  C2</option>
<option value="c3">  C3</option>
<option value="chemistry-keywords">  Keywords</option>
Option value does match e.g. biology in sections is also biology(parent) in categories
{Edited to add Textile’s bc. for readability. – Uli}
Last edited by uli (2014-03-12 16:07:16)
Offline
Re: Filtering categories based on the chosen section (back end)
Waou!
How to a member problem become a plugin. Great community !
I’m just a question to bloke and etc plugin code :
Wath the difference since
echo script_js(<<<EOJS
Your JS code
EOJS);
and
echo n.script_js('Js code');
to inject JS code into a page ?
Offline
#21 2014-03-12 16:30:20
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,319
Re: Filtering categories based on the chosen section (back end)
From the browsers I tried, the JS only worked on FF (27 Mac). Failed on Chromium, SAF & OP. Unfortunately I can’t help with that sort of troubleshooting.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Filtering categories based on the chosen section (back end)
Hohooo,
display:none don’t work for Chrome and IE for option.
This work only with Firefox…
stackoverflow.com/questions/9234830/how-to-hide-a-option-in-a-select-menu-with-css
Last edited by sacripant (2014-03-12 17:14:46)
Offline
Re: Filtering categories based on the chosen section (back end)
sacripant wrote #279696:
Waou!
How to a member problem become a plugin. Great community !
You said it, I remembered it but I don’t know if it still works: bot_write_tab_customize
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline
#25 2014-03-13 10:34:27
- a7aylor
- New Member
- From: Manchester, UK
- Registered: 2014-03-11
- Posts: 9
Re: Filtering categories based on the chosen section (back end)
sacripant wrote #279698:
display:nonedon’t work for Chrome and IE foroption.
This work only with Firefox
Probably why Bloke’s PHP solution would be a better all-rounder; no cross browser issues.
Bloke, I really cant fatham this…
Like you said, if the match is with names (which it is) .val() should do the job in your code. Ive tried changing names and titles so they ALL match (just incase there was a miss-match), the plugin is active, ive created a form called section_cats listing section names (and titles – just to be safe) on seperate lines. Still she’s not purring. Anything else I could try to narrow it down?
Thanks for everyones input, the helps been above and beyond.
Last edited by a7aylor (2014-03-13 10:39:22)
Offline
Re: Filtering categories based on the chosen section (back end)
a7aylor wrote #279716:
Anything else I could try to narrow it down?
A long shot: did you set the plugin’s Type to ‘Admin’ in plugin composer, so it runs on the admin side?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#27 2014-03-13 11:27:27
- a7aylor
- New Member
- From: Manchester, UK
- Registered: 2014-03-11
- Posts: 9
Re: Filtering categories based on the chosen section (back end)
Bloke wrote #279717:
A long shot: did you set the plugin’s Type to ‘Admin’ in plugin composer, so it runs on the admin side?
Ha, I wish that was it! But yeah, its set to Admin only and Ive tried a variety of load orders too.
…
Ive just found out what it is though. Should have guessed it earlier…IE! Not by my choice but our school is stuck on IE9 for the time being, and most of the usage will be internal for this system.
Just tested it on Mac/Safari and it worked perfectly for category1, just not category2. How would I add that in?
Im guessing the IE issue is related to what sacrapant brought up about option tags and such.
I owe you a pint!
Last edited by a7aylor (2014-03-14 08:06:18)
Offline