Page 1 of 1

Trying to build my first extension, but need help

Posted: Fri Apr 06, 2012 6:53 pm
by supersonictt
Hello,
I am very new to EB, and the extension I build is very simple, it doesn't have any javascript files, just <script>.
So there is a variable:
var my_str = "Hello, try it yourself";
In EB, how do I allow users to change "Hello, try it yourself" so the user can put whatever they wish?
Thanks.

Re: Trying to build my first extension, but need help

Posted: Fri Apr 06, 2012 7:09 pm
by Adendum
Hi,

Two things needed.....

[1] set the variable string in my_str between $ in the whatever section the variable needs to appear - so it will look like $my_str$

[2] In the Properties section you need to allow the user to specify the value of $my_str$. So add a category and then add a property. Enter a name for the property (which gets transcribed as the variable name - but you can edit that after), enter the other values, make the TYPE and edit field and you're done.

Re: Trying to build my first extension, but need help

Posted: Fri Apr 06, 2012 7:27 pm
by supersonictt
Adendum wrote:Hi,

Two things needed.....

[1] set the variable string in my_str between $ in the whatever section the variable needs to appear - so it will look like $my_str$

[2] In the Properties section you need to allow the user to specify the value of $my_str$. So add a category and then add a property. Enter a name for the property (which gets transcribed as the variable name - but you can edit that after), enter the other values, make the TYPE and edit field and you're done.
Thanks for the reply :)
hmmm, that didn't work properly!!
Should it be like this:
var my_str = "$here$";
and in properties: Type: edit
Variable: $here$
?

Re: Trying to build my first extension, but need help

Posted: Fri Apr 06, 2012 7:35 pm
by Adendum
supersonictt,

Yes, sorry I didn't properly read the first post. As the code is actualy script the variable will have to go between " marks so where you want

var my_str = "Hello, try it yourself";

to be a variable you would replace it with

var my_str = "$my_variable$";

And you can have whatever name you want for that variable string - doesn't have to be my_var. When you specify the name in the properties you'll probably use something sensible and easy to understand, like Name of Country which will result in a variable name of $nameofcountry$ so your script code would then read

var my_str = "$nameofcountry$";

:)

Re: Trying to build my first extension, but need help

Posted: Fri Apr 06, 2012 7:46 pm
by supersonictt
Yes, that worked that way :)
Initially, the extension works, but still, it has other variables which will need more testing... Plus, I could make it work when page loads as an event.
Would you like to have a look at it? Personally, I liked the script :) that's why am trying to make it as an extension for WWB users to use it.
Thanks a lot for your help :)

Re: Trying to build my first extension, but need help

Posted: Sat Apr 07, 2012 8:53 am
by Adendum
Sure. As the PM system is disabled you will need to contact me via my web site. Email me from there so I get your email address and then you will be able to email me back with an attachment.

Re: Trying to build my first extension, but need help

Posted: Sat Apr 07, 2012 9:40 am
by BaconFries
@ supersonictt can I bring this to your attenion before building and sharing extensions. please ensure that you have permission to use the script, do not use scripts that you have scraped for another site HTML source code, please provide a link back to the original author of the script, check the copyright can it be distributed freely etc etc.... you can read more about the rules of this at the following
viewtopic.php?f=42&t=17899

Re: Trying to build my first extension, but need help

Posted: Sat Apr 07, 2012 11:42 am
by supersonictt
@BaconFries
Thanks for pointing this out. I will do this for sure, and now, I am just trying things out with EB.
I will contact the developer of the script and ask him for permissions to use it :)
Thanks a lot for reminding me :)