SSL Labs ScoreSecurityHeaders.io ScoreHSTS Preloaded

Log in to participate

There is no cost to join RicheyWeb, and membership is a requirement to submit bug reports and participate in the support forums.

× Extension Discussions

Info about Fields - Subform

More
2 months 3 weeks ago - 2 months 3 weeks ago #3912 by iorbita
Hello,
I discovered your plugin by chance and it seems that it could really suit me to structure differently Joomla repeatable fields. Honestly Joomla repeatable fields are very useful but are too limited.

Here is my problem.
As you can see the structure of a repeatable Joomla field is separated by a comma, so if I want to structure and target a field it's just impossible. The ideal would be to enclose each field in a tag.

Can your plugin do it?
According to your video it seems so, but since I am quite limited in the English I prefer to ask you the question :)


Thank you and have good day,

Lorenzo
Attachments:
Last edit: 2 months 3 weeks ago by iorbita.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #3913 by michael
Replied by michael on topic Info about Fields - Subform
I would need to understand better what you're asking for. Joomla repeating fields data (created by my extension) are stored in a JSON structure. For example, lets say you have a repeating field (names) with 3 inputs. names: first, middle, last

That data would be stored like this:

{"names0":{"first":"Michael","middle":"S","last":"Richey"},"names1":{"first":"Io","middle":"R","last":"Bta"},"names2":{"first":"Alfred","middle":"E","last":"Newman"}}

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago - 2 months 2 weeks ago #3915 by iorbita
Replied by iorbita on topic Info about Fields - Subform
Hello,
I don’t know if you watched the screenshot attached to my previous post, as you can see Joomla repeated fields have 3 inputs too, the example is the same as yours except that in my case I’m referring to restaurant dishes (Dish name, dish price and dish description).
The problem is that in the DOM these three inputs are structured in a list and each input is separated by a comma, like this:
<div class="field-entry  ">
    <span class="field-value">
        <ul>
            <li>Poulet Karamel, 8 euros, Pilons de poulet caramélisés à la sauce aigre-douce</li>
            <li>Kisoa ribs, 8 euros, Travers de porc caramélisés à la sauce barbecue</li>
        </ul>
    </span>
</div>

…so if I want to target a field in the DOM it's just impossible. The ideal would be to wrap each field in a tag, like this:
<div class="field-entry  ">
    <span class="field-value">
        <ul>
            <li><span>Poulet Karamel</span><span>8 euros</span><span>Pilons de poulet caramélisés à la sauce aigre-douce</span></li>
            <li><span>Kisoa ribs</span><span>8 euros</span><span>Travers de porc caramélisés à la sauce barbecue</span></li>
        </ul>
    </span>
</div>
... or like this:
<div class="field-entry  ">
    <span class="field-value">
        <div>
            <p><span>Poulet Karamel</span><span>8 euros</span><span>Pilons de poulet caramélisés à la sauce aigre-douce</span></p>
            <p><span>Kisoa ribs</span><span>8 euros</span><span>Travers de porc caramélisés à la sauce barbecue</span></p>
        </div>
    </span>
</div>
The important thing for me is to wrap inputs inside a tag.

Can your plugin change the field’s DOM structure ?

Thank you,

Lorenzo
Last edit: 2 months 2 weeks ago by iorbita.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #3916 by michael
Replied by michael on topic Info about Fields - Subform
I'm sorry. I didn't notice the screenshot in your post. You're concerned about the output, not the data storage method.

OK, with my extension, all data elements are stored in JSON structures. This is important, because the output can be created by the plugin automatically - or it can be tailored using an output template.

On this page, you can download an example that uses a custom output template:
www.richeyweb.com/subform-packages

This isn't exactly what you're asking for, but it shows how you can take the input data (field data) and do whatever you want with it. This particular field doesn't display the data at all, it creates meta tags used by Twitter. The data is available within the output template and you can manipulate it in any way you want. I wrote this plugin because I wasn't happy with the way Joomla forces data formats onto site owners... I wanted more control.

I can write up another example, if you need it.

When Joomla 3.10 is released, there is supposed to be another additional feature available - nested subforms. I'll be releasing an update when that happens.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #3917 by iorbita
Replied by iorbita on topic Info about Fields - Subform
Hello and thank you for your answer, but I've a question: to use your plugin, you have to be a developer?
In my case I can consider structuring an xml file but I'm not really a developer ...
If you could provide me another simpler example, like the one you showed in your first answer (which looks like my example), it would help me better understand your plugin's approach

Thank you again,

Lorenzo

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago - 2 months 2 weeks ago #3918 by michael
Replied by michael on topic Info about Fields - Subform
OK, let's assume the XML is something like this:
(for Dish: name, price, description)
<?xml version="1.0" encoding="UTF-8"?>
<form>
    <fieldset>
        <field type="text" name="name" label="Name" description="Dish Name"/>
        <field type="text" name="price" label="Price" description="Dish Price"/>
        <field type="text" name="description" label="Description" description="Dish Description"/>
    </fieldset>
</form>

When you create your field type "Subform", you'll choose the name for your field "Dish", and type in the full path to this XML file, and select the repeating option.

This will cause your data to be stored like this:
{
    "dish0":{
        "name":"Hot Dog",
        "price":"5.00",
        "description":"tasty lips and buttholes"
    },
    "dish1":{
        "name":"Lemonaid",
        "price":"2.00",
        "description":"Citrus, with a hint of fly poop"
    }
}

If you did NOT choose to write an output template, your data would be displayed in an HTML table with 3 columns - Name, Price, Description. No matter how many dishes you entered, they would all be in the table.

If you choose to create a template (or pay someone to create a template), they would have access to the raw JSON data and could do virtually anything they wanted to do with it. Using your example output (this may not work exactly - I'm just tossing this out there):
class SubformDish {
    public function __construct($json) {
        // the div is created by Joomla
        echo '<ul class="field-value or-your-custom-classname">';
        foreach((array)json_decode($json) as $dish) {
            echo '<li class="dish">';
            echo '<span class="name">'.$dish->name.'</span>';
            echo '<span class="price">'.$dish->price.'</span>';
            echo '<span class="description">'.$dish->description.'</span>';
            echo '</li>';
        }
        echo '</ul>';
    }
}
new SubformDish($value);

And that's about it. I added a couple of extra CSS classes in there to make targeting elements easier.
Last edit: 2 months 2 weeks ago by michael.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Powered by Kunena Forum