在猪跑啦上面看到这段代码
http://www.drupalla.com/node/560
//上一篇 //下一篇 //style: img : 图片形式 text:文字形式 //pn 1:prev 2:next function yourmodulename_get_pn_node($nid, $type, $style = 'img', $pn = 1) { $output = ""; $sql = "SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, files.uri AS uri FROM {node} node left join (SELECT image.entity_id, f.uri FROM {field_data_field_image} image LEFT JOIN {file_managed} f ON image.field_image_fid=f.fid) files ON node.nid=files.entity_id WHERE node.status = '1' AND node.type='".$type."'"; switch ($pn) { case 1: $sql .= " AND node.nid <" .$nid; $title = "上一页"; break; case 2: $sql .= " AND node.nid >" .$nid; $title = "下一页"; break; } $sql .= " ORDER BY node_created desc LIMIT 1 OFFSET 0"; $result = db_query($sql); //也可以db_select 方式, 写法类似。 $output .= "<div class=\"pn pn".$pn."\">"; while ($row = $result->fetchObject()) { $output .= "<div class=\"img\">"; if($row->uri) {$output .= l("<img src=\"".file_create_url($row->uri)."\" alt=\"".$row->node_title."\" height=\"75\">", "node/".$row->nid, array('html'=>true));} else {$output .= l("<img src=\"/sites/default/files/default_images/no-img.gif\" alt=\"".$row->node_title."\" height=\"75\">", "node/".$row->nid, array('html'=>true));} $output .= "</div>"; $output .= l($title, "node/".$row->nid); } $output .= "</div>"; return $output; }
然后在node.php输出
<?php print module_invoke('yourmodulename', 'get_pn_node', $nid, $type, 'img', 1); //上一篇 ?> <?php print module_invoke('yourmodulename', 'get_pn_node', $nid, $type, 'img', 2); //下一篇 ?>
现在输出的是这样子
<div class="pn pn1"><div class="img"><a href="/works/gym"><img src="http://website.com/sites/default/files/project-1-landscape.jpg" alt="健身会所" height="75"></a></div><a href="/works/gym">上一页</a></div> <div class="pn pn2"><div class="img"><a href="/works/app"><img src="http://website.com/sites/default/files/mobile-app-2.jpg" alt="APP演示网站" height="75"></a></div><a href="/works/app">下一页</a></div>
现在我想定制成这样子,图片可以不要
<div class="col-xs-4"> <a href="/works/gym" class="text-left"> <h5 class="mrg-top-15"><i class="ti-arrow-left pdd-right-10 font-size-10"></i> 上一页</h5> </a> </div> <div class="col-xs-4"> <a href="single-2.html" class="text-right"> <h5 class="mrg-top-15">下一页 <i class="ti-arrow-right pdd-left-10 font-size-10"></i></h5> </a> </div>
请问应该怎么修改这段代码?
标签
Drupal 版本