Jump to content

4 identical templates but with different text: could become one?


Recommended Posts

Hi, I wrote a text that sometimes repeats the same in a template, but not always. Sometimes I change it, sometimes it stays the same, but the template is always the same!

I would like to understand if the processwire CK editor has a method or field to retrieve this text written in a .php file via the wireinclude function, at one's free choice. I don't need it all the time. With the .php/wireinclude method, on the other hand, it is like pasted into all the pages of the template and I cannot replace it... the alternative is to create 4 identical templates... but with different text...

Link to comment
Share on other sites

On 2/22/2024 at 7:09 AM, cwsoft said:

Why not simply adding a field with default text to the template, which you can overwrite on pages when needed. Then you just display the text of that field. 

If I added a field with default text, I would have it on ALL PAGES USING THAT TEMPLATE. Instead I would like to choose: on one page yes yes, on the other page no. I guess then I would be better off making 3 templates all the same but with only that different text... I think

Link to comment
Share on other sites

9 hours ago, franciccio-ITALIANO said:

If I added a field with default text, I would have it on ALL PAGES USING THAT TEMPLATE. Instead I would like to choose: on one page yes yes, on the other page no. I guess then I would be better off making 3 templates all the same but with only that different text... I think

You have a field on a template which shows the default text. Than on page 1 and 2 you are fine with the default text, but for page 3 you change it to whatever you want via backend admin. Hence one field with default text and one single template, which is used by three pages in my example. The default text can be overwritten on specific pages and kept unchanged on the other pages.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 2/25/2024 at 10:13 AM, franciccio-ITALIANO said:

If I added a field with default text, I would have it on ALL PAGES USING THAT TEMPLATE. Instead I would like to choose: on one page yes yes, on the other page no. I guess then I would be better off making 3 templates all the same but with only that different text... I think

Leaving the field empty IS the choice here. It's just that the choice is binary, but you're also opting to use 3 templates, making me think you just need a "pick between multiple" mechanic.

Why not add a template that represents just that bit of text (let's call it a Sentence page for now), make three Sentence pages with it (each with a different bit of text), and then in your original template make a Page Reference field that filters out only Sentence pages: now you can pick which sentence you want to use every time you make a new page with your original template. If you ever need a 4rth Sentence you just make a new Sentence page.

Link to comment
Share on other sites

@franciccio-ITALIANO, everyone here gives good options. But it seems that either you are not yet into PW or PHP deep enough to fully grasp the answers or we just have not understood your case well enough. Please provide more details (like screenshots or code snippets) to help us help you better)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...