If Statements in template files??

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 :)

Quote · 6 Sep 2012

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.
Quote · 6 Sep 2012

Have to agree... that would be an awsome addition....

Quote · 6 Sep 2012

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....
Quote · 6 Sep 2012

 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....
Quote · 6 Sep 2012

 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.
Quote · 6 Sep 2012

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.

[bx_if:admin] [/bx_if:admin] would display whats in between those keys only if an admin is viewing the block.

So yes. It will be limited.

But i will be adding a surprise key to the next version which i hope to have released today that if used properly will solve most problems.

https://www.deanbassett.com
Quote · 17 Sep 2012

 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.
Quote · 17 Sep 2012

Tests are being done now on my site.

http://www.deanbassett.com

The home page has a block showing lines that will be displayed if key matches a member logged in.

Keys tested there are

[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]

If you will notice. I also have a bx_php tag which treats the code between the tags exactly as if it were a PHP block. Due to the tinymce editor some things may not work, but lots of stuff will.



On a profile page. Bottom left. http://www.deanbassett.com/Deano

An entire set of keys like the ones already included are being tested. These ones however are for use with profile page blocks and display information on the profile being viewed rather than the logged in member.

I am testing these now. Due to how long it took to finish them, it will not be released today, but should be by tomorrow after testing is complete.

https://www.deanbassett.com
Quote · 17 Sep 2012

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.
Quote · 17 Sep 2012

 

Absolutely outstanding! 

What about a few for groups like

bx_if_fan

bx_if_not_fan

Ok, those 2 are done.

Of course that could be accomplished with the new bx_php tag. But yea, a tag makes it easier.

Any More?



https://www.deanbassett.com
Quote · 18 Sep 2012

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.
Quote · 18 Sep 2012

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.
Quote · 18 Sep 2012

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?

Quote · 18 Sep 2012

 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.
Quote · 18 Sep 2012

lol  dude  go to bed already.... 

https://dolphin-techs.com - Skype: Dolphin Techs
Quote · 18 Sep 2012

 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.
Quote · 18 Sep 2012

Honestly I couldn't understand 99% of it...

Quote · 18 Sep 2012

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.
Quote · 18 Sep 2012

Yes. Unlike Terms

Quote · 18 Sep 2012

If those are the only two words you understood, then by my calculations you understood 1.98% of it.

https://www.deanbassett.com
Quote · 19 Sep 2012

lol

Quote · 3 Oct 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.