Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using variables in blogger posts

I'm using blogger to make a podcast. It works really well, but I find myself copy/pasting a lot of things, when two or three variables and a template would do the job really well.

Most of the posts look like this:

Étude de Exode 6.14-7.13.
<br />
<audio controls>
  <source src="file.mp3" type="audio/mpeg">
  <embed height="50" width="100" src="file.mp3">
</audio>

<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="Ex6.14-7.13"></biblia:bible>

Where three things change:

  • the text on top ("Étude de Exode 6.14-7.13." in the example)
  • the link to the sound file (which is actually data:post.link, but I can't seem to be able to use expr:src there unfortunately)
  • the references passed to the biblia:bible tag (here 'Ex6.14-7.13')

Is there a way I could use a template and variables for my blog posts instead of copying and changing things manually every time?

like image 707
raphink Avatar asked Aug 21 '15 20:08

raphink


1 Answers

You can, however, convert a string object into valid Blogger XML data. So, first, you need to write this object as your post content (make sure you are in the HTML mode):

{
  text: "Étude de Exode 6.14-7.13.",
  source: "file.mp3",
  ref: "Ex6.14-7.13"
}

After that, inside your blog template, find <data:post.body/> then replace with this:

<b:with var='param' expr:value='data:post.body'>
  <data:param.text/>
  <br/>
  <audio controls='controls'>
    <source expr:src='data:param.source' type='audio/mpeg'/>
    <embed height='50' width='100' expr:src='data:param.source'/>
  </audio>
  <biblia:bible layout='minimal' resource='lsg' width='400' height='600' historyButtons='false' navigationBox='false' resourcePicker='false' shareButton='false' textSizeButton='false' expr:startingReference='data:param.ref'/>
</b:with>

Here’s the basic concept: https://www.dte.web.id/2018/07/custom-blogger-widget.html

like image 143
Taufik Nurrohman Avatar answered Oct 20 '22 01:10

Taufik Nurrohman