EzPortal - Portal Software for Forums

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

UserBox

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

+- Recent Posts

New built in translations for six langauges! by EzPortal
March 26, 2024, 11:15:32 pm

Smiley missing in shoutbox 2.1.4 by hustreamload
July 26, 2023, 08:14:02 am

Re: Theme Select Box question? by Shades
March 15, 2023, 06:49:49 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 02:09:24 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 01:55:53 pm

Re: Theme Select Box question? by EzPortal
March 09, 2023, 01:47:42 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 01:34:07 pm

Re: Theme Select Box question? by EzPortal
March 09, 2023, 12:20:17 pm

+- HTML Menu


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

Recent Topics ezBlock

New built in translations for six langauges! by EzPortal
March 26, 2024, 11:15:32 pm

Smiley missing in shoutbox 2.1.4 by hustreamload
July 26, 2023, 08:14:02 am

Theme Select Box question? by Shades
March 15, 2023, 06:49:49 pm

Where is the facebook button color? by EzPortal
February 28, 2023, 06:45:09 pm

Display on Mobile - SMF 2.1.3 and EZ 5.5.2 by BugginIn
December 29, 2022, 04:07:13 pm

Blocks Help by Riggs1973
November 20, 2022, 12:59:30 pm

Surface ol lite theme release Free! by Steffen K.
November 18, 2022, 03:57:24 am

Undefined index: href by EzPortal
October 04, 2022, 08:49:59 pm

SMF-ezportal_column_5.cache): failed to open stream: No such file or directory by EzPortal
June 04, 2022, 11:40:13 am

Arcade block error: failed to open stream: No such file or directory by Shades
May 20, 2022, 02:47:13 pm

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

0 Members and 1 Guest are viewing this topic.

Offline chadon

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
  • Gender: Male
    • Forum Camaro
Different code depending of user's selection
« on: September 24, 2009, 05:57:27 pm »
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>

Offline EzPortal

  • Administrator
  • *****
  • Posts: 1299
  • Karma: 67
Re: Different code depending of user's selection
« Reply #1 on: September 24, 2009, 06:00:35 pm »
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/

Offline chadon

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
  • Gender: Male
    • Forum Camaro
Re: Different code depending of user's selection
« Reply #2 on: September 24, 2009, 06:26:15 pm »
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.

Offline EzPortal

  • Administrator
  • *****
  • Posts: 1299
  • Karma: 67
Re: Different code depending of user's selection
« Reply #3 on: September 24, 2009, 06:40:12 pm »
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/

Offline chadon

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
  • Gender: Male
    • Forum Camaro
Re: Different code depending of user's selection
« Reply #4 on: September 25, 2009, 05:09:15 am »
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. :)



Offline peterwhite88

  • Posts: 1
  • Karma: 0
Re: Different code depending of user's selection
« Reply #5 on: November 28, 2010, 01:04:52 am »
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
6369 Views
Last post August 27, 2011, 05:53:20 am
by kmccann
12 Replies
17301 Views
Last post September 19, 2010, 06:28:25 pm
by FireDitto
1 Replies
13607 Views
Last post August 25, 2012, 11:33:27 am
by amwebby
2 Replies
3940 Views
Last post April 29, 2013, 06:31:01 am
by denden60
1 Replies
31105 Views
Last post October 12, 2020, 07:55:08 am
by EzPortal

+-SMF Gallery

Quick Menu


Powered by EzPortal