SSL Labs ScoreSecurityHeaders.io Score

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

Field - Subform Packages

More
5 months 3 weeks ago #1121 by michael
michael created the topic: Field - Subform Packages
Pre-built subform packages:
Twitter Card
This package includes all of the...

Pre-built subform packages:

Twitter Card

This package includes all of the fields, translations, and metadata template.

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

More
3 months 1 week ago #2292 by BodgeIT
BodgeIT replied the topic: Field - Subform Packages
Is this the documentation for the plugin?

I can see what it's doing. I just have no idea how to replicate it.

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

More
3 months 1 week ago #2295 by michael
michael replied the topic: Field - Subform Packages
Super easy. There is the XML file itself, which defines the form. If your data lends itself to being displayed in a table, the plugin will take care of that for you, using the field labels as the column headings on the table.

If not, you can create an output template PHP file, just name it the same as the XML file and place it in the same directory. The subform value will be available to your script as the variable $value. In my example, I created a PHP class to handle all of the stuff I was doing, but that isn't necessary. You can bust up the $value using json_decode and handle the data any way you see fit.

If your subform needs custom fields, the twittercard example shows how to do that, and if you need to translate the twittercard example shows that too.

Don't let the output template intimidate you. Start with "<?php echo $value;" and go from there. If you can write PHP, you will do fine.
The following user(s) said Thank You: BodgeIT

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

More
3 months 1 week ago - 3 months 1 week ago #2298 by BodgeIT
BodgeIT replied the topic: Field - Subform Packages
Hi Michael, thanks for the reply.
I've got over my initial confusion, I had a different expectation for how to configure the whole thing i.e. just adding in fields by selection. But I'm pretty sure your plugin will help me get to where I need to be.

What I want to achieve is a selectbox for a user to choose a subform for article info.
That might be embedded video info, author info, article references, credits etc.

What I don't want, is to have to show all that on a page when some will not be used, I'd just like the relevant fields be available when they're needed. (these things will only be one or the other i.e video info or pdf info, not both)
It can do that right?

And can I put subforms in a subform?
I'd like to join some fields together i.e for url it should always have "url text" and title fields so 1 url field + 2 text fields (displayed as one item)
Can it do that? I'm assuming I can load as many subforms as I want into one form?

Which of the fields in your twittercard is a custom field? They all just look like normal fields.
Last Edit: 3 months 1 week ago by BodgeIT.

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

More
3 months 1 week ago #2301 by michael
michael replied the topic: Field - Subform Packages
You'll want to spend some time reviewing what can be done with JForm XML - because my subform plugin can do most of it.

I've found myself making super complex subforms, only to realize that I can have as many subform fields as I want. Try to conceptualize your data in discrete units of related data elements. So, for your video info, make a subform with a checkbox and all of the related video info fields. When the user checks the "this is a video" checkbox, the rest appear using the showon="video:1" JForm XML attribute. Same for PDF and others. This way you aren't making forms so complex that they can't work. My plugin will display valid JForm XML - but it's possible to paint yourself into a logical corner by making a form too complex to actually work.

subform within subform - yes and no. Yes it can be done, but nested subforms cannot have multiple values (yet, there's a PR which implements that feature in either Joomla 3.9 or 3.10)

The twitter card custom field injects javascript into the article edit page. Have a look at the XML and you'll see a field named javascript. Then look in the fields folder for the javascript.php file and you'll see what gets injected. The javascript is basically a custom field validator for twitter usernames.
The following user(s) said Thank You: BodgeIT

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

More
3 months 1 week ago #2303 by michael
michael replied the topic: Field - Subform Packages
Here's an example (from this site) of me breaking up the data into many subforms (every green + is a repeating subform field). First I was writing a super complex subform, until I painted myself into a corner. So I started over and painted myself into another corner. Fast forward a half dozen tries to come up with a data model that worked - I realized that I didn't need to cram all of the values I wanted into the subform, I just needed to make several subforms to cover the types of data I was storing.

In my output templates, if the data doesn't exist - the output template exits early. So instead of building logic to handle different types differently - you could create subforms to hold the data you want, and if it's not there the subform field displays nothing.

That approach greatly simplified what I was initially making way too complex.
Attachments:

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

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Kunena Forum