我主要是一个WordPress的人,并试图学习Drupal 7的绳索。我的问题涉及到模板的最佳实践和安全问题。我正在处理极其复杂的设计(耶设计师正确!?),所以我的标记需要干净,恰到好处,我发现Drupal使模板文件和函数的层次结构变得非常困难。基本上,我发现一直在为我工作的工作流是覆盖特定内容类型的输出,我需要在节点级别真正专用的标记。Drupal自定义模板安全问题
因此,例如:节点 - 定制化内容type.tpl.php
就像我说我是一个WordPress的家伙,我习惯了能够运行一个数据库查询,抢确切场我想要的值,然后使用它们。我一直KPR或打印出$变量数组,学习它包含什么,直接抓像这样的值:
$link = $variables['field_link'][0]['url'];
$link_title = $variables['field_link'][0]['title'];
$target = $variables['field_link'][0]['attributes']['target'];
$text = $variables['field_main_text'][0]['safe_value'];
然后echo'ing并在标记使用的变数正是我想:
<article class="getstarted-wrapper">
<a id="tocollege" target="<?php print_r($target); ?>" title="<?php print_r($link_title); ?>" href="<?php print_r($link); ?>"><img src="/sites/all/themes/amped/images/visiticon.png" /></a>
<a id="mapcollege" target="_blank" title="View Location In Google Maps" href="<?php echo $maplink; ?>"><img src="/sites/all/themes/amped/images/mapicon.png" /></a>
<div class="getstarted-top" style="background:<?php print_r($bg); ?>;">
<figure>
<img title="<?php print_r($auth_title); ?>" alt="<?php print_r($auth_alt); ?>" src="<?php print_r($auth_img); ?>" />
</figure>
</div><!--getstarted-top-->
<div class="getstarted-bottom">
<p><?php print_r($text); ?></p>
<a target="<?php print_r($target); ?>" title="<?php print_r($link_title); ?>" href="<?php print_r($link); ?>">Get Started</a>
<span>This will take you to <?php print_r($college_name); ?></span>
</div><!--getstarted-bottom-->
</article><!--getstarted-wrapper-->
我想知道如何这个过程对最佳实践相匹配,我究竟做错了什么,我在做什么的权利,更重要的是我有哪些安全风险和如何避免它们?
感谢您的回复,我唯一的其他问题(不知道您是否是问这个问题的人)是关于如何将此工作流与Drupal最佳实践相匹配?是否有更好的方式来完成相同的任务等? –
我对Drupal并不熟悉,但快速浏览一堆模板似乎表明,完全容易受到XSS的影响绝对是行业标准。 :-( – bobince