HTML5 Data Bindings Support Product Page
Answered
show class if URL = ID of record
Asked 20 Oct 2013 13:45:17
1
has this question
20 Oct 2013 13:45:17 Andre Bender posted:
How do I show a css class if the URL parameter matches the ID in a recordset? I have the following code:<ul class="nav nav-pills nav-stacked" data-binding-repeat-children="{{rsDataset.data}}" data-binding-id="repeat1"> <li class="active"><a href="#">{{DataTitle}}</a></li> </ul>
The class "active" should only be shown, if the URL parameter matches the ID of the record showing.
Replies
Replied 21 Oct 2013 08:46:23
21 Oct 2013 08:46:23 Teodor Kuduschiev replied:
Hello,
I am afraid this is not possible.
I am afraid this is not possible.
Replied 21 Oct 2013 08:51:24
21 Oct 2013 08:51:24 Andre Bender replied:
Hi Teodor. That's a pitty. So I have to use "classic php" again.
Replied 21 Oct 2013 10:31:33
21 Oct 2013 10:31:33 Teodor Kuduschiev replied:
Hi again,
It seems i lied to you, you can achieve this using an expression:
where url-parameter is the url parameter you are using and recordID is your record id.
It seems i lied to you, you can achieve this using an expression:
class="{{($URL.url-parameter == recordID).then("active")}}"
where url-parameter is the url parameter you are using and recordID is your record id.
Replied 21 Oct 2013 10:42:11
21 Oct 2013 10:42:11 Andre Bender replied:
Ok, now I've got to go back form classic php to your extension
Thanks a lot.
It would be great to have a detailed description of how to program with your extension...
btw is this also possible?
Thanks a lot.
It would be great to have a detailed description of how to program with your extension...
btw is this also possible?
class="{{($URL.url-parameter == recordID).then("active").else("inactive")}}"
Replied 29 Oct 2013 20:43:21
29 Oct 2013 20:43:21 Andre Bender replied:
Is there a documentaion planned for these kind of expressions for your extensions? It lokks like there is much more under the hood than shown in the manual which only contains the tutorials.
Replied 18 Nov 2013 10:51:43
18 Nov 2013 10:51:43 Andre Bender replied:
That doesn't seem to work.
class="{{($URL.WTID == WTID).then("active"}}" doesn't show the class Active.
I've also tested:
class="{{($URL.WTID == "50".then("active"}}"
class="{{($URL.WTID == WTID).then("active"}}" doesn't show the class Active.
I've also tested:
class="{{($URL.WTID == "50".then("active"}}"
Replied 19 Nov 2013 09:36:02
19 Nov 2013 09:36:02 Andre Bender replied:
Any ideas?
Replied 21 Nov 2013 13:12:40
21 Nov 2013 13:12:40 Andre Bender replied:
Any support on this?
Replied 25 Nov 2013 17:28:07
25 Nov 2013 17:28:07 Andre Bender replied:
No replies anymore?!
Replied 28 Nov 2014 13:41:33
28 Nov 2014 13:41:33 Andre Bender replied:
I have a URL parameter "MAGID" and the ID "MAGID" and I try to add the lass "active" to a li like this:
<li class="{{($URL.MAGID == MAGID).then("active"}}"><a href="index.php?MAGID={{MAGID}}">{{Magazin}}</a></li>
But that doesn't seem to work Is the code correct?
<li class="{{($URL.MAGID == MAGID).then("active"}}"><a href="index.php?MAGID={{MAGID}}">{{Magazin}}</a></li>
But that doesn't seem to work Is the code correct?
Replied 28 Nov 2014 13:47:50
28 Nov 2014 13:47:50 Teodor Kuduschiev replied:
Try adding this to the LI:
where '-CLASSNAME' is the name of your class, in your case, should be '-active'
data-binding-class-CLASSNAME="$URL_PARAMETER_NAME == DATA_ELEMENT_NAME"
where '-CLASSNAME' is the name of your class, in your case, should be '-active'
Replied 28 Nov 2014 14:04:09
28 Nov 2014 14:04:09 Andre Bender replied:
I've added
<li data-binding-class-active="$URL_PARAMETER_NAME == DATA_ELEMENT_NAME"><a href="index.php?MAGID={{MAGID}}&tp3=1_3">{{Magazin}}</a></li></ul>
Now all links are yellow ...
<li data-binding-class-active="$URL_PARAMETER_NAME == DATA_ELEMENT_NAME"><a href="index.php?MAGID={{MAGID}}&tp3=1_3">{{Magazin}}</a></li></ul>
Now all links are yellow ...
Replied 28 Nov 2014 14:09:46
28 Nov 2014 14:09:46 Teodor Kuduschiev replied:
Sorry it should be in your case:
data-binding-class-active="{{$URL.MAGID == MAGID}}"
data-binding-class-active="{{$URL.MAGID == MAGID}}"
Replied 28 Nov 2014 14:27:59
28 Nov 2014 14:27:59 Andre Bender replied:
Works. Thanks Teodor!