7

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?

raphink
  • 3,625
  • 1
  • 28
  • 39
  • What kind of interface would you like for such template editing ? You are certainly aware of the existence of the [blogger API](https://developers.google.com/blogger/docs/3.0/reference/posts/insert) – dvhh Aug 29 '15 at 17:51
  • I'd like to avoid maintaining an external system using the API. Instead, I was wondering if variables could be declared/used in post templates, like they can be in the blog template and widgets. – raphink Aug 30 '15 at 19:57

2 Answers2

2

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

Taufik Nurrohman
  • 3,329
  • 24
  • 39
1

I am not personally familiar with blogger, but it looks like you can create a widget, and assign variables that way:

<html
 xmlns  = 'http://www.w3.org/1999/xhtml' 
 xmlns:b  = 'http://www.google.com/2005/gml/b' 
 xmlns:data = 'http://www.google.com/2005/gml/data' 
 xmlns:expr = 'http://www.google.com/2005/gml/expr' 
>

<b:includable id='post' var='post'>

<data:post.title/>
<br />
<audio controls>
  <source src="<data:post.file/>" type="audio/mpeg">
  <embed height="50" width="100" src="<data:post.file/>">
</audio>

<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="<data:post.reference/>"></biblia:bible>

</b:includable>

and then to use it...

<b:include name='post' data='p' cond='index < 10'/>

This is a total crap shoot though as I have never used blogger personally, this is just from documentation.

I am referencing material from here:

https://support.google.com/blogger/answer/46995?hl=en

http://thoughtsomething.blogspot.com/2009/01/understanding-blogger-template-1.html

http://helplogger.blogspot.com/2014/03/how-to-create-custom-color-and-font-variable-definitions-to-blogger.html

Addo Solutions
  • 1,619
  • 3
  • 20
  • 37
  • It looks ok, but I couldn't get it to work at all. I'll have to try harder. Widgets apparently can't be used inside posts from what I can tell. – raphink Sep 03 '15 at 12:30