quickjeff

Multiple Fields in One Template

Recommended Posts

Hi Guys, 

I recently have received a client who has various page layouts. I wanted to give them the ability to simply add their HTML into a body field with CKEditor to allow HTML customization.

However, the client isn't very familiar with HTML.

This has left me to build a template that has multiple of the similar field types.

The thing is, I cannot use the repeater since I cannot repeat lets say an image for repeated item 1 and only body field for repeater item 2.

Therefore, I have to literally add 15 fields for them to totally be able to edit the page without issues.

What are your thoughts on this approach?

Also, I have to name the template according to what it contains, so I was thinking of using numbers instead of words.

Reason being, numbers can describe the amount of title fields, body fields and images.

Therefore something like, 3-3-2.php or three-three-two.php 

I have never run into a situation where the client needed so many fields. I was always able to get around it with repeaters etc. 

Thoughts?

Share this post


Link to post
Share on other sites

If I understood correctly, you are trying to get some kind of a content builder. So your client can add a section with copy, then a section with a copy and an image and so on. I suggest you use Repeater Matrix for that. If you cannot afford the subscription, use Page Table from the core. But... just buy Repeater Matrix) There are other ways, but this one's the best.

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites

You can turn Repeater into a kind of poor man's Repeater Matrix by adding all the fields you need to the Repeater, then adding a Page Reference field at the top to select the type of item. Use inputfield dependencies to show/hide inputfields according to what type is selected.

  • Like 4

Share this post


Link to post
Share on other sites

Right, something like this would be good. I may try this approach. Any thoughts on my other approach?

5 hours ago, Ivan Gretsky said:

If I understood correctly, you are trying to get some kind of a content builder. So your client can add a section with copy, then a section with a copy and an image and so on. I suggest you use Repeater Matrix for that. If you cannot afford the subscription, use Page Table from the core. But... just buy Repeater Matrix) There are other ways, but this one's the best.

 

Share this post


Link to post
Share on other sites
30 minutes ago, Robin S said:

You can turn Repeater into a kind of poor man's Repeater Matrix by adding all the fields you need to the Repeater, then adding a Page Reference field at the top to select the type of item. Use inputfield dependencies to show/hide inputfields according to what type is selected.

Once again another great use for a brilliant module! I am sure we haven't yet touched the surface of what can be done with it :)

  • Like 1

Share this post


Link to post
Share on other sites

btw, if you want to see something like this in action, check out this: 

Clicking around, I was first puzzled how certain pages were assembled.

Share this post


Link to post
Share on other sites
10 hours ago, quickjeff said:

Any thoughts on my other approach?

Yes

16 hours ago, quickjeff said:

I wanted to give them the ability to simply add their HTML into a body field with CKEditor to allow HTML customization.

Bad idea, IMHO. I've never heard anything good come out of letting clients dabble in the HTML. Not sure if PageTable Extended can help in your case. I don't think there's any module that will allow you to repeat fields 'unevenly', i.e. in repeater 1, let's repeat title and headline but in repeater 2, let's only body field, etc. Maybe you can use repeaters with some showIf? or inject your own JavaScript and markup to toggle visibility of fields as per need? E.g. tick a box for use this field...will display the field for editing....Just thinking out loud here.

16 hours ago, quickjeff said:

Therefore something like, 3-3-2.php or three-three-two.php 

It might seem like the easy way out, but honestly, will you remember what these mean when you need to edit something in the future? What if you add or remove a field, do you head back to the template file to rename it? I'd be more descriptive in my naming.

Just my 2p.

Edit:

Btw, ProFields will give you both Table and Repeater Matrix. Take your pick!

Also..what Robin said! Inputfield Dependencies!

 

Edit2: I didn't know repeater matrix allows different types of fields in one repeater!

Edited by kongondo
inaccuracy

Share this post


Link to post
Share on other sites
1 minute ago, kongondo said:

Facepalm! How long have I been around here for? :-[:-XI didn't know Repeater Matrix allows different types of repeater items in the same repeater! Thanks @Ivan Gretsky!

It's a fantastic way to give editors a way to control page content without mangling things into an RTE. Also, if you happen to have any sites around where you have used PageTable fields for this and feel like an upgrade to RepeaterMatrix, take a look at the one click converter included in AdminActions.

  • Like 5

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mwjt42
      How do you include fields in Twig templates?
      Tried using {% $page->Title %}, but that creates an error.
      Thanks
    • By Livius
      Hello fellow Process wire Developers!
      Today i have encountered an issue using the repeater where I can't find out how to solve it therefore i am asking for help.
      To be specific, I am trying to get the "file" field working properly in the repeater but i couldn't find a way on how to assign a property of a field that is being used by the repeater.
      download_pdf is the name of the field that i want to access properties from.
      What i wished i could do was something like $download->download_pdf.size or $download->download_pdf->name, something like that but obviously these didn't work
      Hope there is a solution and thanks in advance!
      Best wishes,
      Livius

    • By EyeDentify
      Hello There fellow PW gurus.

      I am trying to make a field show as open only if the field is filled out with at string.
      for example: "my_styles.css" and stay hidden if the field is empty.

      The field in question is of type "text" if that helps.

      And i put in the "show this field only if"
      css_filename!=''

      because the field name is "css_filename"

      But no mather what the field is closed because i have choosen it as "closed" as default.

      What am i doing wrong?

      i am running PW 3.0.83 Dev.
       


    • By bobbit6k
      Hi guys, 
       
      is there a way to declare numbers other than integer and float?
       
      My issue is that intgere is not enough for me because i'm dealing with multiple of bilions (let's say something like 111,532,372,567)
       
      Thanks,
       
      Rob