4

We have inherited a development stage Magento site, where a lot of the blocks on the frontend are horribly misspelled. We are having to go through each block and edit them. One thing we noticed is that these rows generated by:

app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.php

are not clickable by href, but rather by js ajax. Is there any way to create an href link so that they can be opened in the browser in tabs? As editing each of these one at a time and not having the option to have more than one block editor at a time is not very time efficient. How would I go about creating a column in this grid programatically to create an "Edit" link that uses an href for $baseUrl in the _prepareColumns() method? I can just copy this file to the local code pool, I do not intend to modify core code, any help is greatly appreciated. If there is a factory method I'm unaware of, google search has not been fruitful in this regard.

Manashvi Birla
8,8739 gold badges29 silver badges53 bronze badges
asked Jul 29, 2013 at 21:07

2 Answers 2

5

To add an 'edit' link to the CMS Static Blocks grid, all you'd have to do is extend that block with your own module and rewrite _prepareColumns. But, I've already done all of this for you while testing :)

See the code below:

app/code/local/YourCompany/YourModule/Block/Cms/Block/Grid.php

<?php
class YourCompany_YourModule_Block_Cms_Block_Grid extends Mage_Adminhtml_Block_Cms_Block_Grid
{
 protected function _prepareColumns()
 {
 parent::_prepareColumns();
 $this->addColumn('action',
 array(
 'header' => Mage::helper('cms')->__('Action'),
 'width' => '50px',
 'type' => 'action',
 'getter' => 'getId',
 'actions' => array(
 array(
 'caption' => Mage::helper('cms')->__('View'),
 'url' => array('base'=>'*/*/edit'),
 'field' => 'block_id'
 )
 ),
 'filter' => false,
 'sortable' => false
 )
 );
 }
}

app/code/local/YourCompany/YourModule/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
 <global>
 <blocks>
 <adminhtml>
 <rewrite>
 <cms_block_grid>YourCompany_YourModule_Block_Cms_Block_Grid</cms_block_grid>
 </rewrite>
 </adminhtml>
 </blocks> 
 </global>
</config>

app/etc/modules/YourCompany_YourModule.xml

<?xml version="1.0"?>
<config>
 <modules>
 <YourCompany_YourModule>
 <active>true</active>
 <codePool>local</codePool>
 </YourCompany_YourModule>
 </modules>
</config>

Adds a 'View' link, as advertised:

enter image description here

answered Jul 29, 2013 at 21:41
1
  • 1
    Thanks so much! I knew it was possible somehow without modifying core code. And you even took care of the xml end as well. Kudos! Marked as answer. Commented Jul 30, 2013 at 2:11
0

You need to put this method into your Grid.php file

public function getRowUrl($row) {
 return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
answered Aug 1, 2016 at 15:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.