0

With this given category field I want to show the article categories.

 <field name="import_category" type="category"label="test"
            description="test" 
            extension="com_test" /> 

I know I need to write a query to pull the categories. But I dont how to use it with the xml in config.xml. Thank you in advance

  • Hello Parvvee - I am sorry - I am little bit confused. You are using already category field, which should display a dropdown field with your categories. No need for a query. Now sure what I am missing with your question... Can you clarify what you are trying to achieve? – FFrewin Apr 24 '16 at 16:01
1

For getting articles' categories inside the xml of your extension:

<field 
    name="mycategory"
    type="category"
    extension="com_content"
    label="Select a category"
    description="Select your desired category" />

In case this field doesn't meet your needs, you can fetch custom data directly from the database using the sql field:

<field
    name="myfield"
    type="sql"
    default=""
    label="Select a category"
    query="SELECT id, title FROM #__categories WHERE extension = 'com_content'"
    key_field="id"
    value_field="title"
    required="true">
    <option value="">Please select your category</option>
</field>

Note that the database prefix should be entered in the form #__

More info on how to use these 2 form fields:

  • thank you very much @FFrewin.. .. .thank you so much ... now that i understand to place the right extension when pulling out the category.. and sql way is also very helpful..thank you .. – Parvvee Apr 24 '16 at 18:26

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.