Pre-configured Magento Widgets

Is there a user interface or software system for using the Preferred Widget feature that is part of the Magento CMS page page?

When adding a widget to the CMS page, the code that displays this widget is in the processing class of the template directive. This code

File: app/code/core/Mage/Widget/Model/Template/Filter.php class Mage_Adminhtml_Cms_PageController extends Mage_Adminhtml_Controller_Action { ... } 

When loading widget parameters, there is the following bit of code

 // validate required parameter type or id if (!empty($params['type'])) { $type = $params['type']; } elseif (!empty($params['id'])) { $preconfigured = Mage::getResourceSingleton('widget/widget') ->loadPreconfiguredWidget($params['id']); $type = $preconfigured['type']; $params = $preconfigured['parameters']; } else { return ''; } 

This code shows the parsing of a widget directive tag for an id value

 {{widget name="foobazbar" id=""}} 

and then load the configuration from the widget model

 public function loadPreconfiguredWidget($widgetId) { $read = $this->_getReadAdapter(); $select = $read->select(); $select->from($this->getMainTable()) ->where($this->getIdFieldName() . ' = ?', $widgetId); var_dump((string)$select); $widget = $read->fetchRow($select); if (is_array($widget)) { if ($widget['parameters']) { $widget['parameters'] = unserialize($widget['parameters']); } return $widget; } return false; } 

When I first came across this code, I assumed that it loads the Widget instance model. However, it is not. Instead, it loads data from the widget/widget class, which corresponds to the widget table.

 mysql> describe widget; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | widget_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | code | varchar(255) | NO | MUL | NULL | | | type | varchar(255) | NO | | NULL | | | parameters | text | YES | | NULL | | +------------+------------------+------+-----+---------+----------------+ 

Is there a user interface or system to add data to this table? Does anyone (whether or not working at Magento Inc.) know if this is a supported feature, or if it is the beginning of something that was abandoned but left for backward compatibility reasons?

+4
source share
2 answers

In a few comments and private posts, this seems to be a private function for the main Magento team and has nothing to do with instance widgets.

0
source

This answer is somewhat off topic, but I'm not sure that it can satisfy your need anyway. I found that you can create widget instances in the CMS admin section> Admin widgets, and then visualize them using the following code:

 $oWidget = Mage::getModel('widget/widget_instance')->load('HomepageTwitter','title'); $oWidgetBlock = Mage::app()->getLayout()->createBlock($oWidget->getType(), $oWidget->getTitle(), $oWidget->getWidgetParameters()); echo $oWidgetBlock->toHtml(); 

Please note that the block is loaded with a header (and not an arbitrary identifier) ​​and that widget parameters are passed to render the block.

+2
source

Source: https://habr.com/ru/post/1337823/


All Articles