Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2014-03-12 15:02:44

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

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

#18 2014-03-12 15:13:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

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">&#160;&#160;B1</option>
<option value="b2">&#160;&#160;B2</option>
<option value="b3">&#160;&#160;B3</option>
<option value="biology-keywords">&#160;&#160;Keywords</option>
<option value="isa">&#160;&#160;ISA</option>
<option value="chemistry">Chemistry</option>
<option value="c1">&#160;&#160;C1</option>
<option value="c2">&#160;&#160;C2</option>
<option value="c3">&#160;&#160;C3</option>
<option value="chemistry-keywords">&#160;&#160;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

#20 2014-03-12 15:46:25

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

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

#22 2014-03-12 17:07:43

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

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

#23 2014-03-12 17:21:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,395
Website GitHub Mastodon Twitter

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

#24 2014-03-12 19:37:31

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Filtering categories based on the chosen section (back end)

sacripant wrote #279696:

Wath the difference since echo script_js(<<<EOJS... and echo n.script_js('Js code');... to inject JS code into a page ?

Stef is using heredoc syntax, me poor-man quotes.

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:none don’t work for Chrome and IE for option.
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

#26 2014-03-13 10:45:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

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

Board footer

Powered by FluxBB