【发布时间】:2012-01-26 16:21:11
【问题描述】:
好的,这就是正在发生的事情。为 Wordpress 使用 Moneypress LE 插件。我能够通过文件“CSL-products_class.php”有效地输出 html,用于带有 Div 标签“buynow”的“立即购买”按钮。问题是无法加载通过我附加的样式表关联的样式。
您可以在查看我的网站http://www.dustinschmidt.com 上的源代码时检查其中一种产品来发现问题。 html 在那里,但没有样式。
添加了以下代码块:
$product_output[] = "<div class=\"{$this->css_prefix}-buynow\">";
$product_output[] =
"<a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber- sprocket-labs\">".'</a>';
$product_output[] = '</div>';
这是“CSL-products_class.php”现在的样子。
<?php
class wpCSL_products__mpcj {
function __construct($params) {
// Properties with default values
//
$this->columns = 1; // How many columns/row in our display output.
foreach ($params as $name => $value) {
$this->$name = $value;
}
}
/*-------------------------------------
* method: display_products
*
* Legacy Panhandler stuff that will eventually come out.
* This method generates the HTML that will be used to display
* the product list in WordPress when it renders the page.
*
*/
function display_products($products) {
$product_output[] = '';
$moneyFormat = get_option($this->prefix.'-money_format');
$linkModifiers = get_option($this->prefix.'-link_modifiers');
$currCol = 0;
foreach ($products as $product) {
// If we are on the first column, start a new row div
//
if ($currCol == 0) {
$product_output[] = '<div class="'.$this->css_prefix.'-row">';
}
$product_output[] = "<div class=\"{$this->css_prefix}-product\">";
$product_output[] = "<h3>{$product->name}</h3>";
$product_output[] = "<div class=\"{$this->css_prefix}-left\">";
$product_output[] = "<a href=\"{$product->web_urls[0]}\" target=\"cyber-sprocket-labs\" $linkModifiers>";
$product_output[] = "<img src=\"{$product->image_urls[0]}\" alt=\"{$product->name}\" title=\"{$product->name}\" />";
$product_output[] = '</a><br/>';
$product_output[] = '<div class="'.$this->css_prefix.'-zoombox">';
$product_output[] = '<a class="thickbox" href="'.$product->image_urls[0].'"> </a>';
$product_output[] = '</div>';
$product_output[] = '</div>';
$product_output[] = '<div class="'.$this->css_prefix . '-right">';
$product_output[] = '<p class="' . $this->css_prefix . '-desc" >'.$product->description.'</p>';
$product_output[] = '<p class="' . $this->css_prefix . '-price">'.$product->currency;
if (function_exists('money_format') && ($moneyFormat != '')) {
$product_output[] =
"$ <a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\" $linkModifiers>".
trim(money_format($moneyFormat, (float)$product->price)) .
'</a>';
} else {
$product_output[] =
"$ <a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\">".
trim(number_format((float)$product->price, 2)) .
'</a>';
}
$product_output[] = '</p>';
$product_output[] = "<div class=\"{$this->css_prefix}-buynow\">";
$product_output[] =
"<a href=\"{$product->web_urls[0]}\" rel=nofollow target=\"cyber-sprocket-labs\">".'</a>';
$product_output[] = '</div>';
$product_output[] = '</div>';
$product_output[] = '<div class="'.$this->css_prefix.'-cleanup"></div>';
$product_output[] = '</div>';
// Move to the next column, if we already hit the max desired
// output columns, close the row and get ready for a new one
//
$currCol++;
if ($currCol == $this->columns) {
$currCol = 0;
$product_output[] = '</div>';
}
}
// We did not end output on the last column
// so we need to close the row div
//
if ($currCol > 0) {
$currCol = 0;
$product_output[] = '</div>';
}
return implode($product_output);
}
}
最后是我的 div 标签“buynow”的 CSS。
.csl_themes-buynow{background:url("../../core/images/buy-now.png") no-repeat;width:175px;height:64px;float:left}
感谢您的帮助, 尘土飞扬
【问题讨论】:
-
其他所有类都可以正常加载吗?例如,"css_prefix}-product\">" 是否加载了正确的类?是的,所有其他类都加载了。这个buynow 类是我要插入的唯一自定义类。看起来样式表本身没有加载,因为当我单击 中的链接时无法访问它。嗯。
标签: css html styles stylesheet