我有catalog_category_default句柄,它有一个像这样的内容引用.
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
<!-- The following code shows how to set your own pager increments -->
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultListPerPage"><limit>10</limit></action>
<action method="setDefaultGridPerPage"><limit>9</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
<action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
<action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>30</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>60</limit></action>
<action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<!--action method="setColumnCount"><count>4</count></action-->
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
</reference>
Run Code Online (Sandbox Code Playgroud)
我想用magento后端的布局更新来更新它,以加载不同的模板,所以该行
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
Run Code Online (Sandbox Code Playgroud)
应该成为
<block …
Run Code Online (Sandbox Code Playgroud) 我正在努力创造我希望有一天会成为Magento公开扩展的部分(这部分我提到因为我在这里做"正确的事"对我来说很重要).我想做的其中一件事是在默认的Magento仪表板中添加一个框,基本上是一个新的"框",与"前5个搜索术语"完全相同,除了我自己的内容.我希望我的新自定义框是显示的最后一个框(理想情况下).
我遇到的问题是,负责呈现仪表板的模板会调出要呈现的特定块,并且这些块嵌套在html中.换句话说,通常存在一个区域,其中子块将被渲染成一个合理的HTML元素,在这种情况下,似乎会呈现特定的块.以下是/app/design/adminhtml/default/default/template/dashboard/index.phtml的内容
<div class="dashboard-container">
<?php echo $this->getChildHtml('store_switcher') ?>
<table cellspacing="25" width="100%">
<tr>
<td><?php echo $this->getChildHtml('sales') ?>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Orders') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastOrders'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastSearches'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Top 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('topSearches'); ?></fieldset>
</div>
</td>
<td>
<div class="entry-edit" style="border:1px solid #ccc;">
<?php echo $this->getChildHtml('diagrams') ?>
<?php if (is_array($this->getChild('diagrams')->getTabsIds())) : …
Run Code Online (Sandbox Code Playgroud) 我有一个矩阵,其尺寸不会是3的倍数,也可能是.我们如何将整个图像分成3*3矩阵的块.(可以忽略不属于3*3倍数的最后一个.此外,3*3矩阵可以保存在数组中.
a=3; b=3; %window size
x=size(f,1)/a; y=size(f,2)/b; %f is the original image
m=a*ones(1,x); n=b*ones(1,y);
I=mat2cell(f,m,n);
Run Code Online (Sandbox Code Playgroud) 如果我有两个代码块并且我想在它们之间切换(例如,出于测试目的),我意识到你可以使用这样的注释:
//*
<chunk #1, active code here>
//*/
/*
<chunk #2, commented out code here>
//*/
Run Code Online (Sandbox Code Playgroud)
然后在它们之间切换我只需要添加一个/
#2以上并/
从#1上面删除一个.我知道IDE有"切换评论"命令,但我认为这更快,更少杂乱.
/*
<chunk #1, active code here>
//*/
//*
<chunk #2, commented out code here>
//*/
Run Code Online (Sandbox Code Playgroud)
这显然是有效的,因为行注释实际上注释掉了/*
所以块注释没有被解析,并且//
实际注释掉的结尾也是如此*/
.
我的问题是,如果有更好的方式通过评论做这样的事情,或者这种方法是否像评论一样"光滑"?
最近,我试图调试一些代码,我的想法让我感到困惑的是我做错了什么.我的问题的简化版本如下:
for(int x = 0; x < [myArray count]; x++);
{
//perform some action
}
Run Code Online (Sandbox Code Playgroud)
问题是我想要执行的操作只会发生一次.当然,我最终注意到问题是我在for循环结束时意外地包含了一个额外的分号.
for(int x = 0; x < [myArray count]; x++);<---- Oops!
{
//perform some action
}
Run Code Online (Sandbox Code Playgroud)
但后来我开始疑惑......为什么那些代码甚至有点工作?事实证明,我的for循环正在执行,然后下面的代码作为"匿名块"运行.
Objective C中的匿名块有什么意义?什么时候/哪里有用?
为什么我的代码不会在Xcode中产生某种警告?我想你可以把一段旧代码扔进一对额外的大括号中,然后你突然把它作为匿名块执行?
所以,这是我在网站上的第一篇文章,但我过去从这个网站获得了相当多的知识,并期待学习更多.我绝对是一个新手,因为我和Magento一起自学成才,所以我很抱歉这篇文章有什么不对.
我正在研究Magento 1.8.1,其中包含一个主题.涉及多个扩展,大多数都是完全自定义的.
问题:我一直试图让公司名称出现在销售订单网格上一段时间,并且运气不错.
首先,我复制了:/ core/Mage/Adminhtml/Block/Sales/Order/Grid.php -to- /local/Mage/Adminhtml/Block/Sales/Order/Grid.php
然后我将_prepareCollection()中的代码更新为:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join(
array('addressTable' => 'sales_flat_order_address'),'main_table.entity_id = addressTable.parent_id AND addressTable.address_type = "billing"',array('billing_company'=>'company'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
Run Code Online (Sandbox Code Playgroud)
将以下内容添加到_prepareColumns:
$this->addColumn('company', array(
'header' => Mage::helper('sales')->__('Bill to Company'),
'index' => 'billing_company',
));
Run Code Online (Sandbox Code Playgroud)
好的,到目前为止一切顺利.一切都按照应有的方式运作,直到我决定将船舶运送到公司真的很好,因为我们的大多数客户都在为其他公司购买.
为了实现这一点,我像以前一样添加了没有问题的列:
$this->addColumn('company', array(
'header' => Mage::helper('sales')->__('Ship to Company'),
'index' => 'shipping_company',
));
Run Code Online (Sandbox Code Playgroud)
该列添加没有问题,除了它不在我放的地方(在shipping_name之前),这只是添加列没有数据.
现在要添加数据,我会在_prepareCollection下添加另一个集合,因为与表中的结算相比,发货信息在不同的行上?像这样?:
$collection->getSelect()->join(
array('addressTable' => 'sales_flat_order_address'),'main_table.entity_id = addressTable.parent_id AND addressTable.address_type = "shipping"',array('shipping_company'=>'company'));
Run Code Online (Sandbox Code Playgroud)
但是当我尝试这个时,我得到一个错误: /core/Mage/Adminhtml/Block/Sales/Order/Grid.php
我在两列之间也有很多冲突.例如,当我没有在_prepareColumns下注释Ship to Company时,它会显示Ship to Company列,其中Bill to Company列应该是.列中也没有数据.一旦我评论向公司发送公司账单并且具有正确的数据.
基本上,我只需要显示Ship to Company Column以及Bill …
我是一个新的java用户.最近我了解到在java中,每个语句都以分号(;)结束,每个块都由一对ob花括号分隔 - {}
(如果我错了,请纠正我).
但在许多地方我发现作家都在说这if
句话.所以我的问题是java statement
和block
java 之间的区别是什么?
提前致谢.
我最近问了一个问题(三个或更多对象的等式测试),我试图确定一种优雅的方式来对一组3个或更多对象进行相等测试.其中一个解决方案是这样的:
array = [1,1,1,1]
array.all? {|x| x == array.first }
Run Code Online (Sandbox Code Playgroud)
我想知道是否可以将它减少到只有一行,这样我就可以做一些像这样解释的东西:
[1,1,1,1].all? {|x| x == [1,1,1,1].first }
#=> true
Run Code Online (Sandbox Code Playgroud)
在某种程度上,我能够引用块所调用的初始对象,而无需先在前一行中声明该对象.在伪代码中,我想要做的是这样的事情:
[1,1,1,1].all? {|x| x == object_being_called_on_by_block.first }
#=> true
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个,但没有用:
[1,1,1,1].all? { |x| x == self.first }
Run Code Online (Sandbox Code Playgroud) 我有一些文本行,如下所示
text1
text1
text1
text1
Run Code Online (Sandbox Code Playgroud)
我想把它们改成
text1
text2
text3
text4
Run Code Online (Sandbox Code Playgroud)
在gvim中有一个简单的方法吗?我知道使用ctrl + v的可视块可以用其他字母替换一个字母.但我不知道如何生成序列号.
帮助赞赏.谢谢
我想要修改一个variable
位置,复制methodname!
语法而不是将新的修改值重新分配给它var
.我可以这样做proc
吗?我还在学习procs
,看到它们非常有用,使用得当.
a = "Santol bag 85.88 www.example.com/products/16785
Shaddock kg 2.94 www.example.com/products/4109
Palm Fig 5kg 94.34 www.example.com/products/23072
Litchee lb 95.85 www.example.com/products/2557"
a = a.split("\n")
linebreak = Proc.new { |text| text.split("\n") }
linebreak![a]
Run Code Online (Sandbox Code Playgroud)
第一次重新分配似乎很麻烦.proc版本我想看看我是否可以内联执行它.这可能吗?