Jump to content

Latest best practice? - dynamic widgets within body field


Peter Knight
 Share

Recommended Posts

 I have a template where a slider widget appears within my clients body tag. It’s never in the same place twice and client wants freedom to add and remove it as they need  

And I wondered if I am up to date on my options in PW to achieve this..

A) use the pro fields matrix field type to allow client to add the premade slider. They can then follow this by adding another body/content field. 

B) make the slider a Hannah code chunk. Client can then add manually or use the Hannah code plugin to insert. 

Are they my 2 main options ? Sometimes the latest methods mentioned in the recent blog posts don’t really make sense to me until I really need a new way to do things and someone says “hey checkout markup regions” etc. there’s possibilly newer ways to execute this. 

Cheers

Link to comment
Share on other sites

2 hours ago, elabx said:

I have sometimes used a combination of repeater matrix with a "identifier field" that is later used as an attribute in a hannah code. 

Thanks for the info. Can you provide an example of your repeater code and the basic Hannah code mechanism?

Link to comment
Share on other sites

For example, I have a Galleries repeater field (or repeater matrix), named galleries and I want to render galleries within a text field. Each repeater has an images and title field. Let's say you fill one repeater item's title field with "Party gallery".

Then, I have a hannah code that has a title attribute available and is used in the text fields like the following:

[[gallery title="Party gallery"]]

Then, in the hannah code's code (?), I do a selection like this one:

$gallery = $pages->get("galleries.title=$title");

That way the $gallery variable will hold the gallery referenced by the title, which can be picked from setting the hannah code attribute making it very flexible cause then you can have all sort of settings and just pick whatever gallery you want.  The pain point for the users is usually going to find out galleries titles, but most users have found it to be quite flexible. Maybe a custom CKEditor toolbar dropdown would complement this approach even better, filling it with gallery names available. Check this awesome module from @Robin S .

  • Like 3
Link to comment
Share on other sites

That’s very helpful. Thanks for taking time to type it all up. 

I really like Hannah Code but I also wish I could store my PHP in files within templates/components or such instead of having to edit and add to a HC

personally it’s esaier for me to edit using sublime text etc than try to tweak a HC 

Link to comment
Share on other sites

22 minutes ago, LostKobrakai said:

You could create hanna codes, which call code stored elsewhere.

True ?

whatd also be great is a module that watched a Real folder where you added your HC chunks. Anything dropped in there would auto create a matching HC in the admin. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...