Hi, is there a way to add if-statements to a templates files?
I find something that should be easy to do, surprisingly difficult with Dolphin. I guess I just don't know how.
Can someone please help me save a few hours?
Thank you :)
Hi, is there a way to add if-statements to a templates files?
I find something that should be easy to do, surprisingly difficult with Dolphin. I guess I just don't know how.
Can someone please help me save a few hours?
Thank you :) |
Some already exists, but only work withing their respective modules. If you search the Dolphin source files for bx_if you'll see what exists. This sort of thing would be a good addition to Deano's Page Block Keys module. Things like: bx_if:admin bx_if:member bx_if:logged bx_if:group_fan ....etc My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Have to agree... that would be an awsome addition.... |
bx_if is a tag used in dolphin template system. In simple terms You have to define condition in the php template file and the tag in template html file like this put this in the template html file <bx_if:admin> <p>You're admin and your name is __name__</p> </bx_if:admin> and in the php file that uses the html file put something like this 'bx_if:admin' => array( 'condition' => isAdmin(), 'content' => array( 'name' => getNickName(getLoggedId()), ) ), Well its just a simple explanation of how to use it but you still need to find the php file and need some knowledge to do this. Good luck so much to do.... |
I don't know how deano will solve this but putting bx_if:admin in template file will not exactly tell the condition of the if statement. but a list of conditions can be used like you have given but it will be limited in functionality. Some already exists, but only work withing their respective modules. If you search the Dolphin source files for bx_if you'll see what exists. This sort of thing would be a good addition to Deano's Page Block Keys module. Things like: bx_if:admin bx_if:member bx_if:logged bx_if:group_fan ....etc
so much to do.... |
RE: I don't know how deano will solve this but putting bx_if:admin in template file will not exactly tell the condition of the if statement. but a list of conditions can be used like you have given but it will be limited in functionality. Some already exists, but only work withing their respective modules. If you search the Dolphin source files for bx_if you'll see what exists. This sort of thing would be a good addition to Deano's Page Block Keys module. Things like: bx_if:admin bx_if:member bx_if:logged bx_if:group_fan ....etc
I would imagine it would be done in a similar manner as all the existing bx_if tags The problem with all the existing tags, is that their usage is very limited to specific template locations. Some tags that could be used globally, would be quite useful. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Yes. Unlike the template parser which you can pass an array of conditions to, you can't do that with the html blocks, so i will be creating single purpose keys. https://www.deanbassett.com |
RE: [bx_if:admin] [/bx_if:admin] would display whats in between those keys only if an admin is viewing the block. ...And that would be quite useful. maybe not [bx_if:admin] [/bx_if:admin], but [bx_if:member] [/bx_if:member], or [bx_if:logged] [/bx_if:logged] would allow you to display member specific content in blocks alongside public content. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Tests are being done now on my site. [bx_if_admin]Only Shown to Admin[/bx_if_admin] [bx_if_guest]Only Shown to Guest[/bx_if_guest] [bx_if_member]Only Shown to Member[/bx_if_member] [bx_if_membership:standard]Only Shown to Membership Standard[/bx_if_membership:standard] [bx_if_age:47]Only Shown to Age 47[/bx_if_age:47] [bx_if_age:0-20]Only Shown to Age 0-20[/bx_if_age:0-20] [bx_if_age:21-30]Only Shown to Age 21-30[/bx_if_age:21-30] [bx_if_age:31-40]Only Shown to Age 31-40[/bx_if_age:31-40] [bx_if_age:41-50]Only Shown to Age 41-50[/bx_if_age:41-50] [bx_if_age:51-60]Only Shown to Age 51-60[/bx_if_age:51-60] [bx_if_age:61-70]Only Shown to Age 61-70[/bx_if_age:61-70] [bx_if_gender:male]Only Shown Males[/bx_if_gender:male] [bx_if_gender:female]Only Shown to Females[/bx_if_gender:female] [bx_php]BxDolService::call('shoutbox', 'get_shoutbox');[/bx_php]
https://www.deanbassett.com |
Absolutely outstanding! What about a few for groups like bx_if_fan bx_if_not_fan My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Absolutely outstanding! What about a few for groups like bx_if_fan bx_if_not_fan Ok, those 2 are done. https://www.deanbassett.com |
I'm sure I can come up with more, but all of those new ones are a real good start. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Here's a few I'd really love to have:
[bx_if_dumbass] Here's how you fill out the Name field...etc. [/bx_if_dumbass] [bx_if_spammer] Please go kill yourself. [/bx_if_spammer] My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
To be honest I feel this whole system is re-inventing the wheel too much, and i hacked my past it for my own purposes. What is the reasoning they did all of this? |
RE: To be honest I feel this whole system is re-inventing the wheel too much, and i hacked my past it for my own purposes. What is the reasoning they did all of this? Yes. bx_if is purpose keys. bx_if is an array of conditions to, you have template systemplate html file. Yes. bx_if is purpose keys. bx_if is purpose keys. Unlike tag in the template html file like tag in the the to, you have template html blocks, you have temple template html blocks, so i with the template html file. Yes. bx_if is put the template put the purpose keys. bx_if is put the the pass a tag in do that with the tem. In single php template php tem. In single template file. Yes. Unlike terms My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
lol dude go to bed already.... https://dolphin-techs.com - Skype: Dolphin Techs |
RE: lol dude go to bed already.... I did eventually, but if felt that one comment was deserving of the thoughtful response I gave. I hope it clears things up for that individual. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Honestly I couldn't understand 99% of it... |
Does that mean you actually understood 1% of it? My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Yes. Unlike Terms |
If those are the only two words you understood, then by my calculations you understood 1.98% of it. https://www.deanbassett.com |
lol |