Skip to main content
added 143 characters in body
Source Link
inrsaurabh
  • 1.7k
  • 3
  • 27
  • 54

UPDATE Custom static block is created now, is there any way through which i can append the created block to some reference like head

In controller we can append like

    $block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'my_block_name_here',
array('template' => 'instagramapi/apislider.phtml')
);

$this->getLayout()->getBlock('head')->append($block);

but how to do this in my situation.

UPDATE Custom static block is created now, is there any way through which i can append the created block to some reference like head

In controller we can append like

    $block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'my_block_name_here',
array('template' => 'instagramapi/apislider.phtml')
);

$this->getLayout()->getBlock('head')->append($block);

but how to do this in my situation.

added 3506 characters in body
Source Link
inrsaurabh
  • 1.7k
  • 3
  • 27
  • 54

config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Maddyboy_Instagramapi>
      <version>0.1.1</version>
    </Maddyboy_Instagramapi>
  </modules>
  <frontend>
    <routers>
      <instagramapi>
        <use>standard</use>
          <args>
            <module>Maddyboy_Instagramapi</module>
            <frontName>instagramapi</frontName>
          </args>
      </instagramapi>
    </routers>
        <layout>
          <updates>
            <instagramapi>
              <file>instagramapi.xml</file>
            </instagramapi>
          </updates>
        </layout>
  </frontend>
  <global>
    <helpers>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Helper</class>
      </instagramapi>
    </helpers>
    <blocks>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Block</class>
      </instagramapi>
    </blocks>
    <models>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Model</class>
        <resourceModel>instagramapi_mysql4</resourceModel>
      </instagramapi>
    </models>
     <events>
            <controller_front_init_routers>
                <observers>
                    <Maddyboy_Instagramapi_model_observer>
                        <type>singleton</type>
                        <class>Maddyboy_Instagramapi_Model_Observer</class>
                        <method>checkForConfigRequest</method>
                    </Maddyboy_Instagramapi_model_observer>
                </observers>
            </controller_front_init_routers>
        </events>
    
  </global>
  <admin>
    <routers>
      <instagramapi>
        <use>admin</use>
        <args>
          <module>Maddyboy_Instagramapi</module>
          <frontName>admin_instagramapi</frontName>
        </args>
      </instagramapi>
    </routers>
  </admin>
  <adminhtml>
    <menu>
      <instagramapi module="instagramapi">
        <title>Instagramapi</title>
        <sort_order>100</sort_order>
        <children>
          <instagramapibackend module="instagramapi">
            <title>Backend Page Title</title>
            <sort_order>0</sort_order>
            <action>admin_instagramapi/adminhtml_instagramapibackend</action>
          </instagramapibackend>
        </children>
      </instagramapi>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <instagramapi translate="title" module="instagramapi">
              <title>Instagramapi</title>
              <sort_order>1000</sort_order>
              <children>
          <instagramapibackend translate="title">
            <title>Backend Page Title</title>
          </instagramapibackend>
              </children>
            </instagramapi>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <instagramapi>
          <file>instagramapi.xml</file>
        </instagramapi>
      </updates>
    </layout>
  </adminhtml>    
    <crontab>
        <jobs>            
            <instagramapi_instagramapicron>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run><model>instagramapi/cron::Instagramapicron</model></run>
            </instagramapi_instagramapicron>
        </jobs>
    </crontab>
</config> 

config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Maddyboy_Instagramapi>
      <version>0.1.1</version>
    </Maddyboy_Instagramapi>
  </modules>
  <frontend>
    <routers>
      <instagramapi>
        <use>standard</use>
          <args>
            <module>Maddyboy_Instagramapi</module>
            <frontName>instagramapi</frontName>
          </args>
      </instagramapi>
    </routers>
        <layout>
          <updates>
            <instagramapi>
              <file>instagramapi.xml</file>
            </instagramapi>
          </updates>
        </layout>
  </frontend>
  <global>
    <helpers>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Helper</class>
      </instagramapi>
    </helpers>
    <blocks>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Block</class>
      </instagramapi>
    </blocks>
    <models>
      <instagramapi>
        <class>Maddyboy_Instagramapi_Model</class>
        <resourceModel>instagramapi_mysql4</resourceModel>
      </instagramapi>
    </models>
     <events>
            <controller_front_init_routers>
                <observers>
                    <Maddyboy_Instagramapi_model_observer>
                        <type>singleton</type>
                        <class>Maddyboy_Instagramapi_Model_Observer</class>
                        <method>checkForConfigRequest</method>
                    </Maddyboy_Instagramapi_model_observer>
                </observers>
            </controller_front_init_routers>
        </events>
    
  </global>
  <admin>
    <routers>
      <instagramapi>
        <use>admin</use>
        <args>
          <module>Maddyboy_Instagramapi</module>
          <frontName>admin_instagramapi</frontName>
        </args>
      </instagramapi>
    </routers>
  </admin>
  <adminhtml>
    <menu>
      <instagramapi module="instagramapi">
        <title>Instagramapi</title>
        <sort_order>100</sort_order>
        <children>
          <instagramapibackend module="instagramapi">
            <title>Backend Page Title</title>
            <sort_order>0</sort_order>
            <action>admin_instagramapi/adminhtml_instagramapibackend</action>
          </instagramapibackend>
        </children>
      </instagramapi>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <instagramapi translate="title" module="instagramapi">
              <title>Instagramapi</title>
              <sort_order>1000</sort_order>
              <children>
          <instagramapibackend translate="title">
            <title>Backend Page Title</title>
          </instagramapibackend>
              </children>
            </instagramapi>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <instagramapi>
          <file>instagramapi.xml</file>
        </instagramapi>
      </updates>
    </layout>
  </adminhtml>    
    <crontab>
        <jobs>            
            <instagramapi_instagramapicron>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run><model>instagramapi/cron::Instagramapicron</model></run>
            </instagramapi_instagramapicron>
        </jobs>
    </crontab>
</config> 
formatting
Source Link
Mohit Kumar Arora
  • 10.2k
  • 7
  • 28
  • 56

Create a static block using a custom mdoulemodule Magento 1.9

In my custom module magento1/app/code/local/Maddyboy/Instagramapi/data/instagramapi_setup/data-upgrade-0.1.0-0.1.1.php

app/code/local/Maddyboy/Instagramapi/data/instagramapi_setup/data-upgrade-0.1.0-0.1.1.php

<?php
$content = 'BLOCK CONTENT HERE';
//if you want one block for each store view, get the store collection
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds();
//if you want one general block for all the store viwes, uncomment the line below
$stores = array(0);
foreach ($stores as $store){
    $block = Mage::getModel('cms/block');
    $block->setTitle('Block title here');
    $block->setIdentifier('block_identifier_here');
    $block->setStores(array($store));
    $block->setIsActive(1);
    $block->setContent($content);
    $block->save();
}

config.xml

app/code/local/Maddyboy/Instagramapi/etc/config.xml

<Maddyboy_Instagramapi>
      <version>0.1.1</version> // changed to 0.1.1
    </Maddyboy_Instagramapi>

magento1/app/design/frontend/base/default/layout/instagramapi.xml

app/design/frontend/base/default/layout/instagramapi.xml

<?xml version="1.0"?>   
<layout version="0.1.1"> 

Still, static block is not shown in the admin pannelpanel.

Create a static block using a custom mdoule Magento 1.9

In my custom module magento1/app/code/local/Maddyboy/Instagramapi/data/instagramapi_setup/data-upgrade-0.1.0-0.1.1.php

<?php
$content = 'BLOCK CONTENT HERE';
//if you want one block for each store view, get the store collection
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds();
//if you want one general block for all the store viwes, uncomment the line below
$stores = array(0);
foreach ($stores as $store){
    $block = Mage::getModel('cms/block');
    $block->setTitle('Block title here');
    $block->setIdentifier('block_identifier_here');
    $block->setStores(array($store));
    $block->setIsActive(1);
    $block->setContent($content);
    $block->save();
}

config.xml

<Maddyboy_Instagramapi>
      <version>0.1.1</version> // changed to 0.1.1
    </Maddyboy_Instagramapi>

magento1/app/design/frontend/base/default/layout/instagramapi.xml

<?xml version="1.0"?>   
<layout version="0.1.1"> 

Still static block is not shown in admin pannel.

Create a static block using a custom module Magento 1.9

In my custom module

app/code/local/Maddyboy/Instagramapi/data/instagramapi_setup/data-upgrade-0.1.0-0.1.1.php

<?php
$content = 'BLOCK CONTENT HERE';
//if you want one block for each store view, get the store collection
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds();
//if you want one general block for all the store viwes, uncomment the line below
$stores = array(0);
foreach ($stores as $store){
    $block = Mage::getModel('cms/block');
    $block->setTitle('Block title here');
    $block->setIdentifier('block_identifier_here');
    $block->setStores(array($store));
    $block->setIsActive(1);
    $block->setContent($content);
    $block->save();
}

app/code/local/Maddyboy/Instagramapi/etc/config.xml

<Maddyboy_Instagramapi>
      <version>0.1.1</version> // changed to 0.1.1
</Maddyboy_Instagramapi>

app/design/frontend/base/default/layout/instagramapi.xml

<?xml version="1.0"?>   
<layout version="0.1.1"> 

Still, static block is not shown in the admin panel.

Source Link
inrsaurabh
  • 1.7k
  • 3
  • 27
  • 54
Loading