App with different themes

SDK Docs: http://installatron.com/developer/apps
SDK GUI Editor: http://installatron.com/editor
Sdesigns
Posts: 11
Joined: Mon Dec 03, 2012 7:32 am

App with different themes

Postby Sdesigns » Tue Dec 04, 2012 7:02 am

Hi,

My app, which is now installing fine (Thanks for all the help) will have about 10 different themes.

Is it possible to add the theme choices to the installation, so depending on theme chosen will import a different .sql file?

Thanks

Phil
Staff
Posts: 488
Joined: Tue Jun 19, 2007 6:06 am

Re: App with different themes

Postby Phil » Tue Dec 04, 2012 10:16 am

Hello,

Yes, this is possible. We recommend using a custom field to handle prompting the enduser. For example, this would add a radio field:

Code: Select all

      <field id="mytheme" type="radio">
         <label>Theme</label>
         <text>select a theme</text>
         <options>
            <option value="theme1">Blue</option>
            <option value="theme2">Red</option>
         </options>
         <set>
            <?php
            // code here to set field. value saved as $this->input["field_mytheme"]
            //@note It's possible to leave this code blank and simply use the variable in the install's PHP code.
            ?>
         </set>
      </field>


And this field can be accessed in the install PHP code as:

[code]$this->input["field_mytheme"]

See the docs here:
http://installatron.com/developer/apps

Thank you,
Phil
Phillip Stier
Installatron Co-Founder

Sdesigns
Posts: 11
Joined: Mon Dec 03, 2012 7:32 am

Re: App with different themes

Postby Sdesigns » Fri Dec 07, 2012 1:44 am

Hi,

Thanks for the reply, so how would I use this to select the .sql that is used to populate the database?

Normally to populate a database it would be something like

Code: Select all

$this->db_import("install/assets/install.sql");


Can I then use something like

Code: Select all

$this->db_import("install/assets/$this->input["field_mytheme"].sql");


Thanks again for the help.

Phil
Staff
Posts: 488
Joined: Tue Jun 19, 2007 6:06 am

Re: App with different themes

Postby Phil » Fri Dec 07, 2012 9:01 pm

Hello,

Sure, that will work. Something like this:

Code: Select all

$this->db_import("install/assets/".$this->input["field_mytheme"].".sql");


Thank you,
Phil
Phillip Stier
Installatron Co-Founder

Sdesigns
Posts: 11
Joined: Mon Dec 03, 2012 7:32 am

Re: App with different themes

Postby Sdesigns » Sat Dec 08, 2012 1:11 am

Phil wrote:Hello,

Sure, that will work. Something like this:

Code: Select all

$this->db_import("install/assets/".$this->input["field_mytheme"].".sql");


Thank you,
Phil


Hi Phil

I understand the punctuation marks and parenthensis, but why the full stop at the beginning?

Code: Select all

".$


Thanks

Tony

Phil
Staff
Posts: 488
Joined: Tue Jun 19, 2007 6:06 am

Re: App with different themes

Postby Phil » Mon Dec 10, 2012 4:53 am

Hello,

This due to PHP's string concatenation syntax. See:

http://php.net/manual/en/language.operators.string.php

Thank you,
Phil
Phillip Stier
Installatron Co-Founder

Sdesigns
Posts: 11
Joined: Mon Dec 03, 2012 7:32 am

Re: App with different themes

Postby Sdesigns » Fri Dec 28, 2012 2:50 am

Hi Phil,

So far it is working great, thanks for all your help.

Is it possible, and if so then how :) , to use a dropdown instead of radio buttons?

Also, what would be the correct way to have a radio button checked by default in the xml file?

Thanks again

Tony

Josh
Staff
Posts: 131
Joined: Wed Jul 07, 2010 3:53 pm
Location: USA

Re: App with different themes

Postby Josh » Fri Dec 28, 2012 4:47 am

Greetings,

Simply change the type to "select" and the options will show up as a dropdown menu.

A default option can be set by adding a "default" parameter. This can be defined using PHP code or as a static XML value. Eg.

Code: Select all

      <field id="mytheme" type="radio" default="theme1">


or:

Code: Select all

      <field id="mytheme" type="radio">
            <default>
            <?php return "theme".mt_rand(1,2);?>
            </default>


Best regards,
Josh


Return to “Application Packaging SDK and Application Customizations”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests