我的TWIG模板引擎有问题。我不太明白发生了什么。当我通过台式电脑浏览我的页面时,一切正常,但当我使用我的手机时,我总是得到相同的三个错误。
未定义索引:个人资料
undefined index:site_fees
未定义的索引:帐户
这些是没有正确定义的线。
$context['_seq'] = twig_ensure_traversable($context["profile"]);
$context['_seq'] = twig_ensure_traversable($context["site_fees"]);
$context['_seq'] = twig_ensure_traversable($context["account"]);
这是整个功能
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['page_list'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 81
echo "
<div class=\"work-listinfo clearfix cnt\" id=\"profile\">
<ul>
";
// line 84
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($context["profile"]);
foreach ($context['_seq'] as $context["_key"] => $context["profile"]) {
// line 85
echo " <li>
";
// line 86
if ((session_get("language_id") == 2)) {
// line 87
echo " <a href=\"";
echo twig_escape_filter($this->env, base_url(), "html", null, true);
echo "how_does_it_work/page_description/";
echo twig_escape_filter($this->env, $this->getAttribute($context["profile"], "id", array()), "html", null, true);
echo "\">";
echo $this->getAttribute($context["profile"], "title_in_french", array());
echo "</a>
";
} elseif ((session_get("language_id") == 3)) {
// line 89
echo " <a href=\"";
echo twig_escape_filter($this->env, base_url(), "html", null, true);
echo "how_does_it_work/page_description/";
echo twig_escape_filter($this->env, $this->getAttribute($context["profile"], "id", array()), "html", null, true);
echo "\">";
echo $this->getAttribute($context["profile"], "title_in_german", array());
echo "</a>
";
} elseif ((session_get("language_id") == 1)) {
// line 91
echo " <a href=\"";
echo twig_escape_filter($this->env, base_url(), "html", null, true);
echo "how_does_it_work/page_description/";
echo twig_escape_filter($this->env, $this->getAttribute($context["profile"], "id", array()), "html", null, true);
echo "\">";
echo $this->getAttribute($context["profile"], "title_in_english", array());
echo "</a>
";
} else {
// line 93
echo " <a href=\"";
echo twig_escape_filter($this->env, base_url(), "html", null, true);
echo "how_does_it_work/page_description/";
echo twig_escape_filter($this->env, $this->getAttribute($context["profile"], "id", array()), "html", null, true);
echo "\">";
echo $this->getAttribute($context["profile"], "title_in_english", array());
echo "</a>
";
}
// line 95
echo " </li>
";
}
我不明白为什么它在我的电脑上正常工作。有没有人有线索?
编辑:它在私有标签中尝试了它仍然是同样的问题。这是TWIG代码。
{% extends 'layouts/home.twig' %}
{% block title %} How it work {% endblock %}
{% block content %}
<div class="inner-banner">
<div class="wrapper">
<div class="inner-title">
<h2>How On Boat Works</h2>
</div>
</div>
</div>
<div class="container clearfix">
<div class="wrapper">
<div class="my-accountcontain content clearfix">
<aside class="my-accountlf how_te_wrk">
<div class="dash-boardnav">
<div class="dash-boardlist">
<ul>
{% for page_list in page_list %}
<li onclick="view_content('{{page_list.id}}')"><a href="javascript:void(0);" id="l_{{page_list.id}}">
{% if (session_get('language_id')==1) %}
{{page_list.pagename_in_english}}
{% elseif (session_get('language_id')==2) %}
{{page_list.pagename_in_french}}
{% elseif (session_get('language_id')==3) %}
{{page_list.pagename_in_german}}
{% elseif (session_get('language_id')==4) %}
{{page_list.pagename_in_spanish}}
{% else %}
{{page_list.pagename_in_english}}
{% endif %}
</a></li>
{% endfor %}
</ul>
</div>
</div>
</aside>
<aside class="my-accountrh how_te_wrk_rt">
{% set counter = 0 %}
{% for page_list in page_list %}
{% set counter = counter + 1 %}
{% set datas = get_how_it_work_page_content(page_list.id) %}
<div class="work-listinfo clearfix cnt" id="{{page_list.id}}" {% if (counter==1) %} style="display:block;" {% endif %}>
<ul>
{% for data in datas %}
<li>
{% if (session_get('language_id')==2) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{data.id}}">
{{ data.title_in_french }}
</a>
{% elseif (session_get('language_id')==3) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{data.id}}">
{{ data.title_in_german }}
</a>
{% elseif (session_get('language_id')==1) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{data.id}}">
{{ data.title_in_english | raw }}
</a>
{% elseif (session_get('language_id')==4) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{data.id}}">
{{ data.title_in_spanish | raw }}
</a>
{% else %}
<a href="{{base_url()}}how_does_it_work/page_description/{{data.id}}">
{{ data.title_in_english | raw }}
</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
<div class="work-listinfo clearfix cnt" id="profile">
<ul>
{% for profile in profile %}
<li>
{% if (session_get('language_id')==2) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{profile.id}}">{{ profile.title_in_french | raw }}</a>
{% elseif (session_get('language_id')==3) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{profile.id}}">{{ profile.title_in_german | raw }}</a>
{% elseif (session_get('language_id')==1) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{profile.id}}">{{ profile.title_in_english | raw }}</a>
{% else %}
<a href="{{base_url()}}how_does_it_work/page_description/{{profile.id}}">{{ profile.title_in_english | raw }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<div class="work-listinfo clearfix cnt" id="who_we_are_2">
<ul>
{% for site_fees in site_fees %}
<li>
{% if (session_get('language_id')==2) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{site_fees.id}}">{{ site_fees.title_in_french | raw }}</a>
{% elseif (session_get('language_id')==3) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{site_fees.id}}">{{ site_fees.title_in_german | raw }}</a>
{% elseif (session_get('language_id')==1) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{site_fees.id}}">{{ site_fees.title_in_english | raw }}</a>
{% else %}
<a href="{{base_url()}}how_does_it_work/page_description/{{site_fees.id}}">
{{ site_fees.title_in_english | raw }}
</a>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="work-listinfo clearfix cnt" id="account">
{% for account in account %}
{% set counter = counter + 1 %}
{% if counter==5 or counter==9 %}
</ul>
{% endif %}
{% if counter==1 or counter==5 %}
<ul>
{% endif %}
<li>
{% if (session_get('language_id')==2) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{account.id}}">{{ account.title_in_french | raw }}</a>
{% elseif (session_get('language_id')==3) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{account.id}}">{{ account.title_in_german | raw }}</a>
{% elseif (session_get('language_id')==1) %}
<a href="{{base_url()}}how_does_it_work/page_description/{{account.id}}">{{ account.title_in_english | raw }}</a>
{% else %}
<a href="{{base_url()}}how_does_it_work/page_description/{{account.id}}">
{{ account.title_in_english | raw }}
</a>
{% endif %}
</a>
</li>
{% endfor %}
</div>
</aside>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script type="text/javascript">
$(document).ready(function() {
$("#area-slide").owlCarousel({
items: 3,
navigation: true,
pagination: false,
});
});
</script>
<script type="text/javascript">
$(window).load(function(){
$("[data-toggle]").click(function() {
var toggle_el = $(this).data("toggle");
$(toggle_el).toggleClass("open-sidebar");
});
});
function view_content(id){
$('.active').removeClass('active');
$('#l_'+id).addClass('active');
$('.cnt').css('display', 'none');
$('#'+id).css('display', 'block');
}
</script>
{% endblock %}