EzPortal - Portal Software for Forums

EzPortal - Made to Fit Your SMF Forum - Glad You Found Us!

Advertise Here +- +-

UserBox

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Recent Posts

ezPortal 7.0 Released! by EzPortal
February 23, 2026, 08:35:20 pm

ezPortal 6.5 Released! by EzPortal
January 18, 2026, 02:46:30 pm

ezPortal 6.0 released! by EzPortal
July 10, 2025, 10:50:58 pm

Re: TinyMCE Editor disapears by ezxenova
May 06, 2025, 07:38:09 am

Re: TinyMCE Editor disapears by DenDen66
March 02, 2025, 06:59:40 am

Re: TinyMCE Editor disapears by DenDen66
February 28, 2025, 08:09:43 am

Re: TinyMCE Editor disapears by DenDen66
February 28, 2025, 07:31:29 am

Re: TinyMCE Editor disapears by EzPortal
February 27, 2025, 06:57:30 pm

+- HTML Menu


Sample HTML Block Usage - You May Custom Code it, as needed!

Recent Topics ezBlock

ezPortal 7.0 Released! by EzPortal
February 23, 2026, 08:35:20 pm

ezPortal 6.5 Released! by EzPortal
January 18, 2026, 02:46:30 pm

ezPortal 6.0 released! by EzPortal
July 10, 2025, 10:50:58 pm

TinyMCE Editor disapears by ezxenova
May 06, 2025, 07:38:09 am

Renaming a page by DenDen66
February 23, 2025, 10:51:22 am

Styling ezBlock by EzPortal
February 19, 2025, 09:15:05 pm

I don't remember how to upgrade by EzPortal
February 05, 2025, 08:44:58 am

ezPortal 5.6 release by EzPortal
January 31, 2025, 11:21:34 am

5.5.4 by EzPortal
January 16, 2025, 08:31:41 pm

Moving a block higher in list by UkuleleMan
December 17, 2024, 07:58:27 am

Author Topic: Different code depending of user's selection  (Read 16350 times)

0 Members and 1 Guest are viewing this topic.

Different code depending of user's selection
« on: »
I created my first ezBlock today and I would like to improve it by allowing users to select different options but I am having trouble finding out how different selected parameters could generate different html or php codes in the block.

Example:

Code: [Select]
<type>select</type>
<required></required>
<title>Select Test</title>
<selectvalues>X,Y</selectvalues>

- If X is selected, generate this code:
Code: [Select]
<blockdata><![CDATA[ php code ]]></blockdata>
- If Y is selected, generate this code:
Code: [Select]
<blockdata><![CDATA[ different php code ]]></blockdata>

Re: Different code depending of user's selection
« Reply #1 on: »
It is by the parameterid

Example in donation ezblock
Code: [Select]
<parameter1>
<type>string</type>
<required>1</required>
<default></default>
<title>PayPal Email</title>
</parameter1>
<parameter2>
<type>string</type>
<required>1</required>
<default>Donation</default>
<title>Donation Item Name</title>
</parameter2>
<parameter3>
<type>float</type>
<required>0</required>
<default>0</default>
<title>Default Donation Amount</title>
</parameter3>

<blockdata><![CDATA[echo '
<div align="center">
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="' . $parameter1 . '">
<input type="hidden" name="item_name" value="' . $parameter2 . '">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="' . $parameter3 . '">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - its fast, free and secure!">
</form></div>';

]]></blockdata>

Note the names $parameter1, $parameter2, $parameter3 in the donation code.
Like ezPortal? Support me at https://www.patreon.com/vbgamer45/

Re: Different code depending of user's selection
« Reply #2 on: »
Yes but in your example the $parameter value is data entered or selected by the user. It can be done easily with numbers or text but I can't ask the users to select the php code they want to use.

For the ezblock I created, I want the users to choose if they want to display random photos, the last submissions, or the most popular and the php value to modify is not something that can be chosen from an admin panel.

Re: Different code depending of user's selection
« Reply #3 on: »
Ah user selection would be a little tricky. You could store the user data in the smf_themes table in the database. The block would need to be able to check for input passed and update/save that information in the themes table.
Like ezPortal? Support me at https://www.patreon.com/vbgamer45/

Re: Different code depending of user's selection
« Reply #4 on: »
No, sorry I am French and not a coder so it's not easy for me to explain but I'll get it. ;D

What I call an user is the person who manages the ezBlocks in a forum.

In your example:
Code: [Select]
<title>PayPal Email</title>The person who manages the ezBlock enters an email address and the $parameter1 value writes what he entered in the code of the ezBlock.

If I follow this idea, I will have to give a choice between one php tag and another one so the $parameter value would write it in the block. Not everyone would understand what the php tag means so instead I want to give the option to choose between "Random photos" and "Last submissions".

If "Random photos" is selected the $parameter tag will have to write a php tag, if "Last submissions" is selected the $parameter value will write a different php tag.

And to give some style to the block I need to give a choice to have the images displayed vertically or horizontally depending if it's a side block or a center block. To do so, the html code to write in the block will be different.

If it's not doable, it's not a big deal, right now I gave the option to edit the php/html content of the block but I don't know if everyone will know what do to so I want to make sure there is no easier way for them to manage this block.

I hope I was clear this time. :)



Re: Different code depending of user's selection
« Reply #5 on: »
I encountered the same issue before and could not solved it. Now it is clear for me. Thanks!

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
8408 Views
Last post August 27, 2011, 05:53:20 am
by kmccann
12 Replies
20041 Views
Last post September 19, 2010, 06:28:25 pm
by FireDitto
1 Replies
17511 Views
Last post August 25, 2012, 11:33:27 am
by amwebby
2 Replies
5471 Views
Last post April 29, 2013, 06:31:01 am
by denden60
1 Replies
35490 Views
Last post October 12, 2020, 07:55:08 am
by EzPortal

+-SMF Gallery

Quick Menu


Powered by EzPortal