2

Is there a way to add dynamic parameter options to a widget?

For example, I know the tutorial here tells you you can set up parameters like this in your widget.xml file:

<?xml version="1.0"?>
<widgets>
<some_unique_widget_name type="block_group/block_path" translate="name description" module="modulename">
    <name>Widget name</name>
    <description>Short widget description</description>
    <parameters>
        <first_option translate="label">
            <!-- General option properties -->

            <!-- Defines if the option is allowed to be empty -->
            <required>1</required>
            ... etc ...

But in my situation, I'd like the parameters to vary based on database values.

Is this possible? Or is there another solution? Or am I looking at this the wrong way entirely?

Thank you.

2

In hindsight, I didn't ask my question very well because I didn't know what I was really looking for. Hopefully this helps someone.

Ultimately, I went for a setup like this:

    <parameters>                                              
        <report_id type="complex" translate="label">          
            <visible>1</visible>                              
            <required>1</required>                            
            <label>Report</label>                             
            <type>label</type>                                
            <helper_block>                                    
                <type>foobar_sqlreport/sqlreport</type>     
                <data>                                        
                    <button translate="open">                 
                        <open>Select Report...</open>         
                    </button>                                 
                </data>                                       
            </helper_block>                                   
            <sort_order>10</sort_order>                       
        </report_id>                                             
    </parameters>                                             

The key to this is the helper_block section, which dynamically loads all my reports from the database. I used the CMS Static Block as a template for creating my own widget settings. You can find a tutorial on how to do that here.

0

Im not 100% sure if this will work, but this question is pretty similar to this question i answered in the past. Basically you are trying to do the same. Again, this is not tested but calling a helper in an XML is possible in another case, and inside the helper you can call any model or whatever you need to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.