Parse error: syntax error, unexpected '<' in

Статус
В этой теме нельзя размещать новые ответы.

SPATLET

Постоялец
Регистрация
12 Июн 2008
Сообщения
84
Реакции
0
Есть такой вод код:

{
// count tooltips
!isset($GLOBALS['yoo_tooltips'])? $GLOBALS['yoo_tooltips'] = 1 : $GLOBALS['yoo_tooltips']++;
// create tooltip
$id = 'yoo-tooltip-' . $GLOBALS['yoo_tooltips'];
$replace = '<div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title). '</div>';
$replace .= "<script type=\"text/javascript\">\n<!--\nwindow.addEvent('domready', function() { new YOOtooltip('". $id ."', '" . plgContentYOOtooltipStripText($tooltip_text). "', { mode: '" . $mode . "', display: '" . $display . "', width: " . $width . ", style: '" . $style . "', sticky: " . $sticky . " }); });\n-->\n</script>" ;
}

Вот в этой строчке $replace = '<div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title). '</div>'; есть див, а вот здесь нет $replace .= "<script type=\"text/javascript\">\n<!--\nwindow.addEvent('domready', function() { new YOOtooltip('". $id ."', '" . plgContentYOOtooltipStripText($tooltip_text). "', { mode: '" . $mode . "', display: '" . $display . "', width: " . $width . ", style: '" . $style . "', sticky: " . $sticky . " }); });\n-->\n</script>" ; Как мне вторую часть кода тоже засунуть в див с классом? Пробовал комбинацию <div class="win">код</div> но у меня появляется оишбка Parse error: syntax error, unexpected '<' in
 
Код:
$replace = '<div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title) . '<script type="text/javascript">\n<!--\nwindow.addEvent("domready", function() { new YOOtooltip("' .$id. '", "' .plgContentYOOtooltipStripText($tooltip_text). '", { mode: "' .$mode. '", display: "' .$display. '", width: ' .$width. ', style: "' .$style. '", sticky: ' .$sticky. ' }); });\n-->\n</script></div>';

Кажется в первом $replace ты используешь ' как разделитель и " внутри выражения, во втором $replace .= наоборот, когда соединяешь, получается ошибка.
 
я так понял что код который вы привели объеденит все в один контейнер div, а мне нужно в два
 
Код:
$replace = '<div class="win"><div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title) . '<script type="text/javascript">\n<!--\nwindow.addEvent("domready", function() { new YOOtooltip("' .$id. '", "' .plgContentYOOtooltipStripText($tooltip_text). '", { mode: "' .$mode. '", display: "' .$display. '", width: ' .$width. ', style: "' .$style. '", sticky: ' .$sticky. ' }); });\n-->\n</script></div></div>';
Так? Или так:
Код:
$replace = '<div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title) . '</div><div class="win"><script type="text/javascript">\n<!--\nwindow.addEvent("domready", function() { new YOOtooltip("' .$id. '", "' .plgContentYOOtooltipStripText($tooltip_text). '", { mode: "' .$mode. '", display: "' .$display. '", width: ' .$width. ', style: "' .$style. '", sticky: ' .$sticky. ' }); });\n-->\n</script></div>';
 
Ошибка пропала, но теперь не работает скрипт. До этого работал
 
может попробуете весь код скрапта выложить?
а то по одной строчке судить об ошибке, думаю, проблематично!
 
<?php

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$mainframe->registerEvent( 'onPrepareContent', 'plgContentYOOtooltip' );

/**
* Plugin that creates tooltips within content
*/
function plgContentYOOtooltip( &$row, &$params, $page=0 ) {
$db =& JFactory::getDBO();
// simple performance check to determine whether bot should process further
if (JString::strpos($row->text, 'yootooltip') === false) {
return true;
}

// Get plugin info
$plugin =& JPluginHelper::getPlugin('content', 'yoo_tooltip');

// expression to search for
$regex = "#{yootooltip\s*(.*?)}(.*?){/yootooltip}#s";

$pluginParams = new JParameter( $plugin->params );

// check whether plugin has been unpublished
if ( !$pluginParams->get( 'enabled', 1 ) ) {
$row->text = preg_replace($regex, '', $row->text);
return true;
}

// add javascript and css
$document =& JFactory::getDocument();
$document->addScript(JURI::base() . 'plugins/content/yoo_tooltip/yoo_tooltip.js');
$document->addStyleSheet(JURI::base() . 'plugins/content/yoo_tooltip/yoo_tooltip.css.php');

// perform the replacement
preg_match_all($regex, $row->text, $matches);
$count = count($matches[0]);
if ($count) {
plgContentYOOtooltipReplace($row, $matches, $count, $regex, $pluginParams);
}
}

function plgContentYOOtooltipReplace(&$row, &$matches, $count, $regex, $params) {
$style = $params->get('style', 'default');

for ($i = 0; $i < $count; $i++) {
$replace = '';
$param_line = $matches[1][$i];
$tooltip_text = $matches[2][$i];
$mode = plgContentYOOtooltipGetParam($param_line, 'mode', $params->get('mode', 'cursor'));
$display = plgContentYOOtooltipGetParam($param_line, 'display', 'inline');
$title = plgContentYOOtooltipGetParam($param_line, 'title', 'Tooltip');
$width = plgContentYOOtooltipGetParam($param_line, 'width', $params->get('width', 300));
$sticky = plgContentYOOtooltipGetParam($param_line, 'sticky', $params->get('sticky', 0));

if ($tooltip_text != '') {
// count tooltips
!isset($GLOBALS['yoo_tooltips']) ? $GLOBALS['yoo_tooltips'] = 1 : $GLOBALS['yoo_tooltips']++;
// create tooltip
$id = 'yoo-tooltip-' . $GLOBALS['yoo_tooltips'];
$replace = '<div id="' . $id . '" class="yoo-tooltip-toggler">' . plgContentYOOtooltipStripText($title) . '</div>';
$replace .= "<script type=\"text/javascript\">\n<!--\nwindow.addEvent('domready', function() { new YOOtooltip('". $id ."', '" . plgContentYOOtooltipStripText($tooltip_text) . "', { mode: '" . $mode . "', display: '" . $display . "', width: " . $width . ", style: '" . $style . "', sticky: " . $sticky . " }); });\n-->\n</script>";
}

$row->text = str_replace($matches[0][$i], $replace, $row->text);
}
}

function plgContentYOOtooltipGetParam($param_line, $attribute, $default = null) {
$matches = array();
preg_match_all('/(\w+)(\s*=\s*\[.*?\])/s', $param_line, $matches);

for ($i = 0; $i < count($matches[1]); $i++) {
if (strtolower($matches[1][$i]) == strtolower($attribute)) {
$result = ltrim($matches[2][$i], " \n\r\t=");
$result = trim($result, '[]');
return $result;
}
}

return $default;
}

function plgContentYOOtooltipStripText($text) {
$text = str_replace(array("\r\n", "\n", "\r", "\t"), "", $text);
$text = addcslashes($text, "'");
return $text;
}
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху