【发布时间】:2015-03-07 20:31:21
【问题描述】:
我在 wordpress 上的目录网站上工作,当我尝试搜索选项时出现此错误:
警告:第 27 行 /home/dalilouk/public_html/wp-content/themes/directory/header.php 中的非法字符串偏移“字段”
警告:第 33 行 /home/dalilouk/public_html/wp-content/themes/directory/header.php 中的非法字符串偏移“字段”
而且搜索的结果总是“没有找到”。
这是第 27 行 header.php 的代码:
<script type="text/javascript"> #line 27
jQuery(document).ready(function($) {
{ifset $themeOptions->search->searchCategoriesHierarchical}
var categories = [ {!$categoriesHierarchical} ];
{else}
var categories = [ #line 33
{foreach $categories as $cat}
{ value: {$cat->term_id}, label: {$cat->name} }{if !($iterator->last)},{/if}
{/foreach}
];
{/ifset}
{ifset $themeOptions->search->searchLocationsHierarchical}
var locations = [ {!$locationsHierarchical} ];
{else}
var locations = [
{foreach $locations as $loc}
{ value: {$loc->term_id}, label: {$loc->name} }{if !($iterator->last)},{/if}
{/foreach}
];
{/ifset}
var catInput = $( "#dir-searchinput-category" ),
catInputID = $( "#dir-searchinput-category-id" ),
locInput = $( "#dir-searchinput-location" ),
locInputID = $( "#dir-searchinput-location-id" );
catInput.autocomplete({
minLength: 0,
source: categories,
focus: function( event, ui ) {
var val = ui.item.label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
catInput.val( val );
return false;
},
select: function( event, ui ) {
var val = ui.item.label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
catInput.val( val );
catInputID.val( ui.item.value );
return false;
}
}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
var catList = catInput.autocomplete( "widget" );
catList.niceScroll({ autohidemode: false });
catInput.click(function(){
catInput.val('');
catInputID.val('0');
catInput.autocomplete( "search", "" );
});
locInput.autocomplete({
minLength: 0,
source: locations,
focus: function( event, ui ) {
var val = ui.item.label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
locInput.val( val );
return false;
},
select: function( event, ui ) {
var val = ui.item.label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
locInput.val( val );
locInputID.val( ui.item.value );
return false;
}
}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
var locList = locInput.autocomplete( "widget" );
locList.niceScroll({ autohidemode: false });
locInput.click(function(){
locInput.val('');
locInputID.val('0');
locInput.autocomplete( "search", "" );
});
{ifset $_GET['dir-search']}
// fill inputs with search parameters
$('#dir-searchinput-text').val({$searchTerm});
catInputID.val({$_GET["categories"]});
for(var i=0;i<categories.length;i++){
if(categories[i].value == {$_GET["categories"]}) {
var val = categories[i].label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
catInput.val(val);
}
}
locInputID.val({$_GET["locations"]});
for(var i=0;i<locations.length;i++){
if(locations[i].value == {$_GET["locations"]}) {
var val = locations[i].label.replace(/&/g, "&");
val = val.replace(/ /g, " ").replace(/'/g, "'");
locInput.val(val);
}
}
{/ifset}
});
</script>
请帮我解决这个问题。
【问题讨论】:
标签: javascript php wordpress warnings