franciccio-ITALIANO Posted February 21 Share Posted February 21 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 More sharing options...
MarkE Posted February 21 Share Posted February 21 Not sure I entirely understand the question, but it sounds like you need Hanna code. 1 Link to comment Share on other sites More sharing options...
cwsoft Posted February 22 Share Posted February 22 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. Link to comment Share on other sites More sharing options...
franciccio-ITALIANO Posted February 25 Author Share Posted February 25 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 More sharing options...
franciccio-ITALIANO Posted February 25 Author Share Posted February 25 On 2/21/2024 at 10:57 PM, MarkE said: Not sure I entirely understand the question, but it sounds like you need Hanna code. I don't want to burden the site with a plugin just for this thing.... Link to comment Share on other sites More sharing options...
gornycreative Posted February 25 Share Posted February 25 On some level, this is what Markup Regions are for. Link to comment Share on other sites More sharing options...
cwsoft Posted February 25 Share Posted February 25 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. 1 Link to comment Share on other sites More sharing options...
Pixrael Posted February 26 Share Posted February 26 Set a placeholder in your text, and use the function wirePopulateStringTags() to output it, filled or empty. https://processwire.com/api/ref/functions/wire-populate-string-tags/ 1 Link to comment Share on other sites More sharing options...
Inxentas Posted April 9 Share Posted April 9 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 More sharing options...
Ivan Gretsky Posted April 9 Share Posted April 9 @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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now