Hi - I am wondering if I am using a remote snippet for our address and I make changes to that snippet, do I need to send any or all designer templates using that particular snippet back through workflow? For example - I am using the address snippet remotely on 5 templates. So, do I need to send all 5 back through workflow if I make a change to the snippet?
Remote snippets are stored outside of the template and each template is accessing them from a certain location. You do not need to resend the template to Workflow or refresh the services when making changes within a remote snippet. (Provided the snippet name remains the same too.)
EDIT: Also this means that you would only make the changes to the .json file that is stored on disk and not editing the .rjson in one of the templates.
Just if you add the snippet content in a script via loadhtml()
Not sure if I understand you correctly. I added the remote snippet in the templates snippet folder and used a script that loads the snippet as per below using a selector/ID and when changing the snippet that is stored in a specific folder I don’t need to worry about the template. I’m talking about a print template though.
var json_m = loadjson(“Snippets/Snippet 1.rjson”);
But please note if you just drag the snippet from the snippet folder in Designer to the layout section (and even if using option “Insert as Shared Content”) you need to resend the template for each modification of the snippet, otherwise the output isn’t updated.
Noted Martin. I don’t drag and drop snippets, so did not know this. In my limited uses of using json stored on disk, I make the changes to the json file and use a positioned box with the same ID as the selector of the script that loads the .rjson file.
EDIT: Please note that I was not talking about editing the json snippet in the designer, only the actual json file on disk.
Hi - I want to make sure I am clear with my original question. I do not use json ( that I am aware of). I have an html file in a folder outside the template. In my template, I click on ‘add new remote snippet’. I then add the html code using the article tag for each of the addresses. For example
In my template I have in the snippet folder - Address.rhtml
In my folder outside the template, the address folder has like nine different address all with their own div id. I have in my template nine article tags for each address based on certain conditions. One of my conditions look like this:
if(record.fields[“HTTP”].includes(“BPAS”)&& record.fields[“IRAIND”]!= “I”){
results.loadhtml(“snippets/Address.rhtml”, “#BPASaddress”).children();
}else if …
I have this in four other templates. So based on your first response, if I make a change to the html snippet int he folder outside my template - I DO NOT need to send each template to workflow, correct?
I only have used json loading via a script and as mentioned above a rjson. I’m not sure about HTML snippets because I have not used them. Perhaps Martin, who works for OL, can shed some light about the rhtml.
In case you want to take it one step further one could use a Content Management System like WordPress to store the address information. Perhaps this goes a bit too far but think it is worth to mention. WordPress comes with a REST API which you can access using the loadjson() command in your templates. We (OL) are using this internally for various solutions and demos.
This will fetch a post with the my-address-block slug in JSON format (is an JSON array with a single entry) from your WordPress site. One could also retrieve the post by its internal WordPress ID.
In Connect Designer scripting it would look something like this:
var addressObj = loadjson('https://www.yourwordpresssite.com/wp-json/wp/v2/posts?slug=my-address-block');
results.html(addressObj[0].content.rendered);
I suggest to download WordPress and install it on a machine on your local network. For this purpose one could use for example a MAMP or WAMP server.
Of course this technique goes way beyond address blocks. Consider use cases like dynamically create datasheets, newsletters, letters, policy documents etc.