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 EyeDentify
      I as have been a bit confused for some time about how the "Markup Regions" functionality in Processwire worked.
      But i have know read a bit more and think that i am getting to grips with it. And Markup Regions is going to be huge.

      To aid me in understanding Markup Regions better i started to read the Source code for the new "Regular" theme in conjunction with the Blog about the markup regions.
      It helped me a great deal to understand the basics and more fine details of it.

      A tip is to open both links and use the Source code of the "Regular" theme while reading the blog post.
       
      The Source code:
      https://github.com/processwire/processwire/blob/dev/site-regular/templates/_main.php
      The Blog post:
      https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/
       
      I hope this could help others starting out with markup regions.
      Just take it slow and read it a couple a times and soon you will see the greatness of markup regions.

      /EyeDentify 
    • By louisstephens
      So I am making a front-end dashboard for an internal project, and was curious if it is possible to match 2 pages together based on their title and retrieve the data.
      To make it more clear:
      I have two pages "Section A"  and "Section B" that each has child pages with names (the specific person) with subpages for their services offered. 
      Section A - John Doe (name=john-doe) - Service 1 - Service 2 - Service 3 - Jane Doe (name=jane-doe) - Service 1 - Service 2 - Service 3 Section B - John Doe (name=john-doe) - Service 4 - Service 5 - Service 6 - Jane Doe (name=jane-doe) - Service 4 - Service 5 - Service 6 What I would like to achieve on the front-end (if it is even possibile), is an output like:
      John Doe - Service 1 - Service 2 - Service 3 - Service 4 - Service 5 - Service 6 Jane Doe - Service 1 - Service 2 - Service 3 - Service 4 - Service 5 - Service 6 Thinking aloud: use a find to get all pages using the template "service user" and then foreaching through their children (and possibly getting a few field values as well) to output in the front end. The service templates used in the sections vary slightly in which fields they use.
      <?php $findUsers = $pages->find("template=service-a (and or) service-b,(some how match based on names)"); //if no match exists, output what is available ?> <ul> <?php foreach ($findUsers as $groupedUser): ?> <li><?php echo $groupedUser->title; ?></li> <li><?php echo $groupedUser->service_a_location; ?></li> <li><?php echo $groupedUser->service_a_body; ?></li> <li><?php echo $groupedUser->service_b_location; ?></li> <li><?php echo $groupedUser->service_b_phone; ?></li> <?php endforeach; ?> </ul> Sorry, it is just me thinking aloud, but I was not even sure if it is possible to group them together like that. I was going to have a page for each "section" only displaying that data, but I thought it would be nice to display them all together as an overview for the user.
    • By dweeda
      How do I migrate a template with all its fields and values to a new site? Is their an export/import process?
    • By rareyush
      I am using module "FormTemplateProcessor" to get data in a pages but they all are unpublished and when I am trying to display them with relevent pages it not working
       
      page1 p1 p2 p3 page2 (FormTemplateProcessor) up1 (unpublished page and have p1 id on field knows as "ID") up2 (unpublished page and have p3 id on field knows as "ID") up3 (unpublished page and have p2 id on field knows as "ID") now here
      up1, ip2, up3 can be created by p1, p2 or p3 and I am saving respectively I'm saving their id in field which is being used by up1,up2,up3, etc template.
       
      now I want to show the data from unpublished pages which belongs to p1, p2 and p3 respectively
       
       
      anyone has experienced this or knows something which can help me out ?
    • By louisstephens
      Just a quick question, I have a function in my ready.php file that creates a new js file inside the "scripts" folder (under templates). Everything is working as expected, however, is it possible for the url to look like www.domain.com/scripts/generated.js ?
       
      Currently, the only way I can access it is via www.domain.com/site/templates/scripts/generated.js. Or is there a better place I should be putting these scripts ? I I am trying to use the scripts elsewhere (not on the processwire install).