在博客帖子中使用变量

时间:2015-08-21 20:41:54

标签: templates blogger

我正在使用博主制作播客。它工作得很好,但我发现自己复制/粘贴很多东西,当两个或三个变量和一个模板能很好地完成工作时。

大多数帖子都是这样的:

+----------+---------------------------------------------------+
| F_Key_ID |                    Concat_Text                    |
+----------+---------------------------------------------------+
|       15 | This is an example that I wished worked correctly |
|       21 | Unique entry                                      |
|       18 | The Eagles are the best football team.            |
+----------+---------------------------------------------------+

有三件事发生变化:

  • 顶部的文字(示例中的“É​​tudedeExode 6.14-7.13。”)
  • 指向声音文件的链接(实际上是É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> ,但遗憾的是我似乎无法使用data:post.link
  • 传递给expr:src标记的引用(此处为'Ex6.14-7.13')

有没有办法可以为我的博客文章使用模板和变量,而不是每次都手动复制和更改内容?

2 个答案:

答案 0 :(得分:1)

我对博主并不熟悉,但看起来你可以创建一个小部件,并以这种方式分配变量:

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

然后使用它......

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

虽然因为我从来没有亲自使用博客,但这只是一个完整的废话,这只是来自文档。

我在这里引用材料:

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

答案 1 :(得分:1)

但是,您可以将字符串对象转换为有效的 Blogger XML数据。因此,首先,您需要将此对象编写为帖子内容(确保您处于 HTML 模式):

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

然后,在您的博客模板中找到<data:post.body/>,然后替换为:

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

基本概念是:https://www.dte.web.id/2018/07/custom-blogger-widget.html

相关问题