Суть такая, есть код:
<?php
global $base_path;
$base_path_theme = $base_path.path_to_theme();
$img = explode('http://',$fields['field_images_fid']->content);
$img2 = explode('http://',$fields['field_images_fid_1']->content);
$img3 = explode('http://',$fields['field_images_fid_2']->content);
$img4 = explode('http://',$fields['field_images_fid_3']->content);
global $allObjectsForMyCategory;
if (!is_array($allObjectsForMyCategory)) $allObjectsForMyCategory = array();
?>
<?php
foreach ($img as $key => $value){
if (trim($value) == '') continue;
echo '<li><a href="http://'.$img3[$key].'" alt="#" ><img src="http://'.$img[$key].'" alt="#" rel="http://'.$img2[$key].'" /></a></li>';
};
?>
Результат такой:
<li>
<a class="ad-thumb0 ad-active" alt="#" href="http://stroimarket.info/sites/default/files/imagecache/232x200/dom_1-1.jpg">
<img field-item-1"="" field-item="" rel="http://stroimarket.info/sites/default/files/dom_1-1.jpg</div><div class=" alt="#" src="http://stroimarket.info/sites/default/files/imagecache/47x50/dom_1-1.jpg" style="opacity: 1;">
" />
</a>
</li>
Но вот здесь ошибка в адресе ссылки(подставляются лишние тэги):
rel="http://stroimarket.info/sites/default/files/dom_1-1.jpg</div><div class="
Не могу понять где и как формируются эти ссылки что бы исправить данный ошибочный путь????
Спустя 10 минут, 13 секунд (27.05.2011 - 11:30) Pirat_BillY написал(а):
А что у тебя в самом индексе?
Спустя 7 минут, 23 секунды (27.05.2011 - 11:38) Michael написал(а):
! |
Michael |
Спустя 6 минут, 34 секунды (27.05.2011 - 11:44) an1401 написал(а):
сайт на друпале,
index.php в корне:
index.php в корне:
<?php
// $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler();
// Menu status constants are integers; page content is a string.
if (is_int($return)) {
switch ($return) {
case MENU_NOT_FOUND:
drupal_not_found();
break;
case MENU_ACCESS_DENIED:
drupal_access_denied();
break;
case MENU_SITE_OFFLINE:
drupal_site_offline();
break;
}
}
elseif (isset($return)) {
// Print any value (including an empty string) except NULL or undefined:
print theme('page', $return);
}
drupal_page_footer();
Спустя 3 минуты, 31 секунда (27.05.2011 - 11:48) Pirat_BillY написал(а):
Я имел ввиду шаблона. Скорее всего там нужно стереть лишнее.
Спустя 2 минуты, 25 секунд (27.05.2011 - 11:50) an1401 написал(а):
в шаблоне нет index.php
есть template.php
есть template.php
<?php
// $Id: template.php,v 1.16.2.3 2010/05/11 09:41:22 goba Exp $
/**
* Sets the body-tag class attribute.
*
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
*/
function phptemplate_body_class($left, $right) {
if ($left != '' && $right != '') {
$class = 'sidebars';
}
else {
if ($left != '') {
$class = 'sidebar-left';
}
if ($right != '') {
$class = 'sidebar-right';
}
}
if (isset($class)) {
print ' class="'. $class .'"';
}
}
/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
* An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
}
}
/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
$vars['tabs2'] = menu_secondary_local_tasks();
// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
}
/**
* Add a "Comments" heading above comments except on forum pages.
*/
function garland_preprocess_comment_wrapper(&$vars) {
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'. $vars['content'];
}
}
/**
* Returns the rendered local tasks. The default implementation renders
* them as tabs. Overridden to split the secondary tasks.
*
* @ingroup themeable
*/
function phptemplate_menu_local_tasks() {
//return menu_primary_local_tasks();
}
/**
* Returns the themed submitted-by string for the comment.
*/
function phptemplate_comment_submitted($comment){
return t('!datetime — !username',array(
'!username' => theme('username', $comment),
'!datetime' => format_date($comment->timestamp)
));
}
/**
* Returns the themed submitted-by string for the node.
*/
function phptemplate_node_submitted($node) {
return t('!datetime — !username',
array(
'!username' => theme('username', $node),
'!datetime' => format_date($node->created),
));
}
/**
* Generates IE CSS links for LTR and RTL languages.
*/
function phptemplate_get_ie_styles() {
global $language;
$iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
if ($language->direction == LANGUAGE_RTL) {
$iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
}
return $iecss;
}
function sm_breadcrumb($breadcrumb) {
//$breadcrumb[0] = '<a href="/"><img alt="#" src="/sites/all/themes/uschenin/images/nav_ico.gif"/></a>';
$uri = check_plain(request_uri());
$parent_material = array();
$field_parent = array();
$args = arg();
if ('/product/'.$args[1] == request_uri() ){
$node = node_load($args[1]);
foreach ($node->field_parent_material as $key => $value){
array_push($parent_material,node_load($value['nid']));
}
}
$node = node_load($args[1]); //;жуууть
if ($node){
if (!empty($node->field_parent[0]->nid)){
array_push($field_parent,node_load($node->field_parent[0]['nid']));
};
};
if (!empty($breadcrumb)) {
$title = drupal_get_title();
if(mb_strpos($_REQUEST['q'],'product') !== false) $breadcrumb[] = 'Продукция';
if (preg_match('/^\/news$/', $uri) !== 0) {
$breadcrumb[] = 'Новости';
}elseif(preg_match('/^\/partner$/', $uri) !== 0){
$breadcrumb[] = 'Партнеры';
}elseif(preg_match('/^\/product$/', $uri) !== 0){
$breadcrumb[] = 'Продукция';
}elseif($args[0] == 'catalog'){
$breadcrumb[] = 'Галерея';
$tax = taxonomy_get_term($args[1]);
$breadcrumb[] = (!empty($args[2])) ? '<a href="/catalog/'.$tax->tid.'">'.$tax->name.'</a>' : $tax->name;
if (!empty($args[2])){
$node = node_load($args[2]);
$breadcrumb[] = $node->title;
}
}elseif(preg_match('/^\/textpage$/', $uri) !== 0){
$breadcrumb[] = 'Текстовая страница';
}elseif(preg_match('/^\/search$/', $uri) !== 0){
$breadcrumb[] = 'Поиск';
}elseif(preg_match('/^\/Site map$/', $uri) !== 0){
$breadcrumb[] = 'Карта сайта';
}elseif(preg_match('/^\/Catalog$/', $uri) !== 0){
//$breadcrumb[] = 'Карта сайта';
}else {
if (count($field_parent) > 0){
foreach ($field_parent as $key => $value){
$breadcrumb[] = "<a href=\"/textpage/{$value->nid}\">".$value->title."</a>";
}
}
if (count($parent_material) > 0){
foreach ($parent_material as $key => $value){
if (empty($value->title)) continue;
$breadcrumb[] = "<a href=\"/material/{$value->nid}\">".$value->title."</a>";
}
}
if (!empty($title)) {
$breadcrumb[] = $title;
};
};
};
for($i = 0;isset($breadcrumb[$i]);$i++){
if (preg_match('/^.*Текстовая страница.*$/', $breadcrumb[$i]) !== 0){
unset($breadcrumb[$i]);
};
if (preg_match('/^.*Catalog.*$/', $breadcrumb[$i]) !== 0){
unset($breadcrumb[$i]);
};
if (preg_match('/^.*Поиск.*$/', $breadcrumb[$i]) !== 0){
unset($breadcrumb[$i]);
};
};
return ''. implode(' <span>/</span> ', $breadcrumb) .'';
}
function sm_all_products(){
if (!empty($allProducts)) return $allProducts;
static $allProducts;
$query = <<<here
SELECT node.nid AS nid,
node_data_field_parent_material.field_parent_material_nid AS node_data_field_parent_material_field_parent_material_nid,
node_data_field_parent_material.delta AS node_data_field_parent_material_delta,
node.type AS node_type,
node.vid AS node_vid,
node.title AS node_title
FROM node node
INNER JOIN content_field_parent_material node_data_field_parent_material ON node.vid = node_data_field_parent_material.vid
WHERE node.type = 'products'
here;
$res = db_query(str_replace(chr(10),' ',$query));
$allProducts = array();
while($row = db_fetch_array($res)){
if (!$row['node_data_field_parent_material_field_parent_material_nid']) continue;
$allProducts[$row['node_data_field_parent_material_field_parent_material_nid']][] = $row;
};
return $allProducts;
}
function sm_view_hardcore_menu($general = false){
global $base_path;
$base_path_theme = $base_path.path_to_theme();
$terms = taxonomy_get_tree(4);
if ($general){
$class = 'main-menu';
}else{
$class = 'main-menu2';
};
$header = <<<here
<div class="{$class}">
<div class="main-menu-top"><img src="{$base_path_theme}/images/menu_top.png" alt="#" /></div>
<div class="main-menu-bg">
<ul>
here;
$allProducts = sm_all_products();
foreach ($terms as $key => $value){
$res = taxonomy_select_nodes(array($value->tid));
$view = false;
$results = array();
$head_body = '';
while ($row = db_fetch_array($res)){
if (strpos('/'.$_REQUEST['q'],'/'.$row['nid'])) $view = true;
$node = node_load($row['nid']);
if ($node->type != 'material')continue;
//$link = l($row['title'],'node/'.$row['nid']);
$link = '/material/'.$row['nid'];
$head_body .= "<li class=\"act\"><a href=\"{$link}\">{$row['title']}</a>";
$issetProduct = false;
if (isset($allProducts[$row['nid']])){
foreach ($allProducts[$row['nid']] as $key2 => $value2){
if (strpos('/'.$_REQUEST['q'],'/'.$value2['nid'])) $issetProduct = true;
};
};
if (isset($allProducts[$row['nid']]) and (strpos('/'.$_REQUEST['q'],'/'.$row['nid']) or $issetProduct)){
$head_body .= '<ul>';
foreach ($allProducts[$row['nid']] as $key2 => $value2){
//$link = l($value2['node_title'],'node/'.$value2['nid']);
$link = '/product/'.$value2['nid'];
$head_body .= "<li><a href=\"{$link}\">{$value2['node_title']}</a></li>";
};
$head_body .= '</ul>';
};
$head_body .= "</li>";
};
$style = '';
if ($view === true) $style = 'style="display:block"';
$header .= "<li><span><a href=\"javascript:return void(0)\" class=\"b-layer\" rel=\"layers{$value->tid}\">{$value->name}</a></span><ul class=\"menu_second_lvl\" {$style}>";
$header .= $head_body;
$header .= '</ul></li>';
}
$header .= <<<here
</ul>
</div>
<div class="main-menu-bot"><img src="{$base_path_theme}/images/menu_bot.png" alt="#" /></div>
</div>
here;
echo $header;
}
function sm_print_products_for_material($idMaterial,$filtered = false){
global $base_path;
$base_path_theme = $base_path.path_to_theme();
$allProducts = sm_all_products();
if ($filtered) return $allProducts[$idMaterial]; //если требуется просто список - возвращаем его
$view = ($allProducts[$idMaterial] > 0)? '<h4>Продукция</h4>' : '' ;
foreach ($allProducts[$idMaterial] as $key => $value){
$node = node_load($value['nid']);
$view .= <<<here
<table>
<tr>
<td><span><a href="#"><img src="{$base_path_theme}/images/prod03.gif" alt="#" /></a></span></td>
<td><p><a href="/product/{$value['nid']}">{$value['node_title']}</a></p></td>
</tr>
</table>
here;
if (!empty($node->body)){
$view .= <<<here
<table>
<tr>
<!--<td><span><a href="#"><img src="images/prod04.gif" alt="#" /></a></span></td>-->
<td>
{$node->body}
</td>
</tr>
</table>
here;
};
};
return $view;
}
function sm_print_all_objects_from_category($idCat){
$res = taxonomy_select_nodes(array(7));
while ($row = db_fetch_array($res)){
//$link = l($row['title'],'node/'.$row['nid']);
$node = node_load($row['nid']);
print_r($node);
};
}
function sm_city_value(){
$return = array();
$pos = array();
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'city' ORDER BY n.sticky DESC";
$res = db_query($sql);
$i = 0;
while ($row = db_fetch_array($res)){
//$link = l($row['title'],'node/'.$row['nid']);
$node = node_load($row['nid']);
if (isset($_GET['asd'])) print_r($node);
$return[] = '<option value="'.$node->nid.'">'.$node->title.'</option>';
$pos[] = (empty($node->field_actual_position[0]['value']))? 0 : $node->field_actual_position[0]['value'];
$i++;
};
//array_multisort($pos,$return);
return implode(chr(10),$return);
}
function sm_city_phone($general = false){
if ($general){
$class = 'phone-box';
}else{
$class = 'phone-box2';
};
$return = '';
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'city' ORDER BY n.sticky DESC";
$res = db_query($sql);
$i = 0;
while ($row = db_fetch_array($res)){
//$link = l($row['title'],'node/'.$row['nid']);
$node = node_load($row['nid']);
if ($i == 0){
$style = 'display:inline';
}else{
$style = 'display:none';
};
$return .= '<div class="'.$class.'" style="'.$style.'" id="'.$node->nid.'_city_phone">тел: <span>'.$node->field_number_phone[0]['value'].'</span></div>';
$i++;
};
return $return;
}
function sm_view_banner(){
$return = '';
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'banner' order by RAND()";
$res = db_query($sql);
$rows_100 = array();
$rows_50 = array();
while ($row = db_fetch_array($res)){
//$link = l($row['title'],'node/'.$row['nid']);
$node = node_load($row['nid']);
if ($node->field_banner_rotate[0]['value'] == '100%'){
array_push($rows_100,node_load($row['nid']));
}elseif($node->field_banner_rotate[0]['value'] == '50%'){
array_push($rows_50,node_load($row['nid']));
};
};
$rows = array_merge($rows_100,$rows_50);
for ($i=0; isset($rows[$i]); $i++){
if ($i == 3) break;
$node = $rows[$i];
$img = theme('imagecache', '94x64',$node->field_banner_image[0]['filepath']);
$body = mb_substr(strip_tags($node->body),0,150,'utf-8');
$return .= "<div><p><a href=\"{$node->field_url_path[0]['value']}\">{$img}</a></p><a href=\"{$node->field_url_path[0]['value']}\">{$body}</a></div>";
};
return $return;
}
function sm_print_products($str,$acompanies = true){
global $base_path;
$base_path_theme = $base_path.path_to_theme();
$nodes = $str;
$nodes = explode('</div>',$nodes);
for ($i=0;isset($nodes[$i]);$i++){
$nodes[$i] = trim(strip_tags($nodes[$i]));
}
for ($i=0;isset($nodes[$i]);$i++){
if ($nodes[$i] == '') continue;
$nodes[$i] = node_load(array('title' => $nodes[$i]));
}
$view = '';
foreach ($nodes as $key => $node){
if (empty($node->title)) continue;
if ($node->type == 'material'){
$type = 'material';
}else{
$type = 'product';
};
$img = '';
if (isset($node->field_image_cache[0])){
$img = $node->field_image_cache[0]['filepath'];
$img = "<span><a href=\"/{$type}/{$node->nid}\">".theme('imagecache', '98x105', $img).'</a></span>';
};
$view .= <<<here
<table>
<tr>
<td>{$img}</td>
<td><p><a href="/{$type}/{$node->nid}">{$node->title}</a></p></td>
</tr>
</table>
here;
/*
if (!empty($node->body)){
$view .= <<<here
<table>
<tr>
<!--<td><span><a href="#"><img src="images/prod04.gif" alt="#" /></a></span></td>-->
<td>
{$node->body}
</td>
</tr>
</table>
here;
};
*/
};
return $view;
}
//надеюсь я такой ужас больше не увижу
function sm_print_objects_from_material($id = 72){
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'object'";
$myNodes = array();
$res = db_query($sql);
$returnVal = '';
$i = 0;
while ($row = db_fetch_array($res)){
$node = node_load($row['nid']);
foreach ($node->field_material_or_product as $key => $value){
if ($value['nid'] == $id){
array_push($myNodes,$node);
continue 2;
};
};
};
foreach ($myNodes as $key => $node){
$imgblok = '';
foreach ($node->field_images as $key2 => $value2){
$logo = $value2['filepath'];
//if ($key == 0) $logo = $value2['filepath'];
$theme = theme('imagecache','47x50',$logo);
$theme_path = imagecache_create_path('232x200',$logo);
$imgblok .= '<li><a href="/'.$theme_path.'" alt="#">'.$theme.'</a></li>';
}
if ($logo) $logo = theme('imagecache','47x50',$logo);
$returnVal .= <<<here
<li>
<a class="zoom" href="#inline{$node->nid}">{$logo}</a>
<a class="zoom" href="#inline{$node->nid}">{$node->title}</a>
<div style="display: none;">
<div id="inline{$node->nid}" class="drop-box">
<table>
<tr>
<td>
<div id="gallery" class="ad-gallery2">
<div class="ad-image-wrapper">
</div>
<div class="ad-nav">
<div class="ad-thumbs">
<ul class="ad-thumb-list">
{$imgblok}
<!--
-->
</ul>
</div>
</div>
</div>
</td>
<td>
<h2>{$node->title}</h2>
{$node->body}
<!--<h3>Используемые материалы:</h3>
<p>{$fields['material_or_product_fid']->content}</p>-->
</td>
</tr>
</table>
</div>
</div>
</li>
here;
};
return $returnVal;
}
function sm_count_objects_from_material($id,$id_category = 0){
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'object'";
$myNodes = array();
$res = db_query($sql);
$returnVal = '';
$arIdVal = array();
$i = 0;
while ($row = db_fetch_array($res)){
if (in_array($row['nid'],$arIdVal) == false){
array_push($arIdVal,$row['nid']);
}else{
continue;
};
//if($row['nid'] == 315) print_r($node->field_material_or_product);
$node = node_load($row['nid']);
//print_r($node->field_material_or_product);
//if($row['nid'] == 315) print_r($node->field_material_or_product);
foreach ($node->field_material_or_product as $key => $value){
if ($value['nid'] == $id and ($id_category == 0 or isset($node->taxonomy[$id_category]))){
array_push($myNodes,$node);
continue 2;
};
};
};
return count($myNodes);
}
function submitted_element(){
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'city'";
$res = db_query($sql);
$txt = '';
$i = 0;
while ($row = db_fetch_array($res)){
$node = node_load($row['nid']);
$id = ($i == 0)? 'id="up_el_option"' : '';
$txt .= "<option {$id} onmousedown=\"document.getElementById('edit-target_email').value='{$node->field_mail[0]['value']}'\" value=\"{$node->title}\">{$node->title}</option>";
$i++;
};
return $txt;
}
//в ад этот код
function sm_generate_sitemap_catalog(){
$allProducts = sm_all_products();
$terms = taxonomy_get_tree(4);
$sql = "SELECT n.nid FROM {node} n WHERE n.type = 'object'";
$myNodes = array();
$res = db_query($sql);
$returnVal = '';
$i = 0;
while ($row = db_fetch_array($res)){
$node = node_load($row['nid']);
array_push($myNodes,$node);
};
foreach ($terms as $key => $value){
$res = taxonomy_select_nodes(array($value->tid));
$view = false;
$results = array();
$head_body = '';
while ($row = db_fetch_array($res)){
if (strpos('/'.$_REQUEST['q'],'/'.$row['nid'])) $view = true;
$node = node_load($row['nid']);
if ($node->type != 'material')continue;
//$link = l($row['title'],'node/'.$row['nid']);
$link = '/material/'.$row['nid'];
$head_body .= "<li class=\"act\"><a href=\"{$link}\">{$row['title']}</a>";
$issetProduct = false;
if (isset($allProducts[$row['nid']])){
foreach ($allProducts[$row['nid']] as $key2 => $value2){
if (strpos('/'.$_REQUEST['q'],'/'.$value2['nid'])) $issetProduct = true;
};
};
//if (isset($allProducts[$row['nid']]) and (strpos('/'.$_REQUEST['q'],'/'.$row['nid']) or $issetProduct)){
if (isset($allProducts[$row['nid']]) and (strpos('/'.$_REQUEST['q'],'/'.$row['nid']) or $issetProduct)){
$head_body .= '<ul>';
foreach ($allProducts[$row['nid']] as $key2 => $value2){
//$link = l($value2['node_title'],'node/'.$value2['nid']);
$link = '/product/'.$value2['nid'];
$head_body .= "<li class=\"act\"><a href=\"{$link}\">{$value2['node_title']}</a></li>";
};
$head_body .= '</ul>';
};
$head_body .= "</li>";
};
$header .= "<li><span><a>{$value->name}</a></span><ul>";
$header .= $head_body;
$header .= '</ul></li>';
}
return <<<here
<div class="catalog-box">
<h2>Каталог</h2>
<ul>
{$header}
</ul>
</div>
here;
}
function sm_site_map_box(){
$html = '';
$html .= <<<here
<div class="map-box">
<h2>Карта сайта</h2>
here;
$menuTree = menu_tree_all_data('primary-links');
$html .= '<ul>';
$firstEl = TRUE;
foreach ($menuTree as $key => $value){
if ($firstEl === TRUE){
$url = url($value['link']['link_path']);
$cellMenu = <<<here
<li><span><a>{$value['link']['title']}</a></span>
here;
$firstEl = FALSE;
}else{
$url = url($value['link']['link_path']);
$cellMenu = "<li><span><a>{$value['link']['title']}</a></span>";
};
if ($value['link']['title'] == 'Галерея'){
$terms = taxonomy_get_tree(4);
$cellMenu .= '<ul>'.chr(10);
foreach ($terms as $key2 => $value2){
$res = taxonomy_select_nodes(array($value2->tid));
$view = false;
while ($row = db_fetch_array($res)){
if (sm_count_objects_from_material($row['nid'],$value2->tid) > 0){
$view = true;
continue;
};
};
if ($view == false) continue;
$cellMenu .= "<li><a href=\"/catalog/{$value2->tid}\">{$value2->name}</a></li>".chr(10);
};
$cellMenu .= '</ul>'.chr(10);
}
if (!empty($value['below']) && count($value['below']) > 0){
$cellMenu .= '<ul>'.chr(10);
foreach ($value['below'] as $key2 => $value2){
$url = url($value2['link']['link_path']);
$cellMenu .= "<li><a href=\"{$url}\">{$value2['link']['title']}</a></li>".chr(10);
};
$cellMenu .= '</ul>'.chr(10);
};
$cellMenu .= '</li>';
$html .= $cellMenu;
};
$html .= <<<here
<li><span><a href="/content/zakazy">Отправить заявку</a></span></li>
</ul>
</div>
here;
$html .= sm_generate_sitemap_catalog();
$html .= <<<here
<div class="clear"> </div>
</div>
here;
return '<div class="txt-box">'.$html.'</div>';
}