Jump to content

Recommended Posts

Posted

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...

Posted

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. 

Posted
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

Posted
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
  • 1 month later...
Posted
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.

Posted

@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)

  • 1 year later...
Posted (edited)

I had a similar case recently where I used a single roadmap template and just swapped content fields based on the page. Each page using that template had its own text, titles, and images pulled from custom fields, so the layout stayed the same but the content was unique. It kept things clean and made updates way simpler down the line.

 

Edited by Dwightsune

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.
×
×
  • Create New...