我有几种自定义内容类型,在一种特定的内容类型中,我需要提供两个字段,一个用于链接的 href,另一个用于链接的文本,这样我就可以在最少用户参与 HTML/ 的情况下构建它并设置其样式。 CSS。我还有一个针对此内容类型的自定义 node.tpl。我的问题是,drupal 在我创建的每个字段周围抛出 div,这些字段不在我的模板文件中用于此内容类型 (node-custom.tpl),并且我无法将带有 div 的链接的 href 放在 内google.co.uk">
查看我的问题。也许我做错了所以欢迎任何其他想法。
请注意,我正在尝试以最少的用户 HTML/CSS 访问参与来创建此网站。我知道我可以在字段中手动编码链接。
I have several custom content types and in one specific one I need to offer two fields, one for the href for a link, and one for the text of a link this way I can build and style it with minimal user involvement of the HTML/CSS. I also have a custom node.tpl for this content type. My problem is that drupal throws divs around each field I create that aren't in my template file for this content type (node-custom.tpl) and I can't put the href for a link with divs around it inside <a href="<div id="something">google.co.uk</div>"></a>
See my problem. Maybe I'm doing this all wrong so any other ideas are welcome.
Please note I'm trying to create this site with minimum involvement of HTML/CSS access for the user. I'm aware I could hand code the link in the field.
发布评论
评论(1)
最简单的方法是在 template.php 文件中使用预处理函数并手动构建链接:
然后在节点模板文件中,您将可以访问变量
$my_link
您可以在任何地方输出,并且将包含链接的正确 HTML。最后,转到您的内容类型的“管理显示”页面,并将不再需要输出的两个字段的显示设置为“隐藏”。还有其他方法,所以如果这不好,请告诉我
编辑
只是补充一下,我认为最简单的方法实际上是安装 链接模块 并使用提供的字段类型而不是您当前正在使用的其他两个字段。
The easiest way to do this would be to use a preprocess function in your template.php file and build the link up manually:
Then in your node template file you'll have access to the variable
$my_link
which you can output anywhere, and will contain the correct HTML for the link. Finally, go to the "Manage Display" page for your content type and set the display of the two fields you no longer need to output to 'Hidden'.There are other ways so if that's no good let me know
EDIT
Just to add, I think the easiest way to do this would actually be to install the Link module and use the provided field type instead of the two other fields you're currently using.