Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 在博客帖子中使用变量_Templates_Blogger - Fatal编程技术网

Templates 在博客帖子中使用变量

Templates 在博客帖子中使用变量,templates,blogger,Templates,Blogger,我在用blogger做播客。它工作得非常好,但我发现自己复制/粘贴了很多东西,而两个或三个变量和一个模板可以很好地完成这项工作 大多数帖子如下所示: É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"> </aud

我在用blogger做播客。它工作得非常好,但我发现自己复制/粘贴了很多东西,而两个或三个变量和一个模板可以很好地完成这项工作

大多数帖子如下所示:

É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>
第6.14-7.13节。

有三件事发生了变化:

  • 顶部的文本(“示例中的埃图德埃克塞德6.14-7.13.”)
  • 指向声音文件的链接(实际上是
    data:post.link
    ,但我似乎无法在那里使用
    expr:src
  • 传递到
    biblia:bible
    标记的引用(此处为“Ex6.14-7.13”)

有没有一种方法可以让我的博客帖子使用模板和变量,而不是每次都手动复制和更改内容?

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

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



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

之后,在您的博客模板中,找到
,然后替换为以下内容:

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



对于此类模板编辑,您希望使用什么样的界面?您肯定知道API的存在,我希望避免使用API维护外部系统。相反,我想知道变量是否可以在帖子模板中声明/使用,就像它们可以在博客模板和小部件中一样。我必须更加努力。据我所知,小部件显然不能在帖子中使用。
{
  text: "Étude de Exode 6.14-7.13.",
  source: "file.mp3",
  ref: "Ex6.14-7.13"
}
<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>