i am using codeigniter. I want to add seo plugin.I found some code,but i don't know how to apply it.My code is,
controllers/seo.php
Class Seo extends CI_Controller {
function sitemap()
{
$data = "";//select urls from DB to Array
header("Content-Type: text/xml;charset=iso-8859-1");
$this->load->view("sitemap",$data);
}
}
views/sitemap.php
<?= '<?xml version="1.0" encoding="UTF-8" ?>' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc><?= base_url();?></loc>
<priority>1.0</priority>
</url>
<!-- My code is looking quite different, but the principle is similar -->
<?php foreach($data as $url) { ?>
<url>
<loc><?= base_url().$url ?></loc>
<priority>0.5</priority>
</url>
<?php } ?>
</urlset>
config/routes.php
$route['seo/sitemap\.xml'] = "seo/sitemap";
How it works on search engine?Any one please help me.
The code pasted by you contains code for 3 files as it shows.
i) controller class of codeigniter application/controllers/seo.php
ii) A view that is loaded by sitemap function of the seo controller. application/views/sitemap.php that outputs an XML Sitemap file.
iii) and a route to be added to the application/config/routes.php
NOTE: The main and only function in this code is incomplete so is useless as it is. You need to add few lines to retrieve data from database & assign it to $data variable.
Once completed it can be used as path to sitemap of your website that will managed via database.
I hope I was able to it make it clear.
Related
Something is not right. CodeIgniter... the output is not in xml format. Just found out an hour ago that i can see the sitemap php page businessclaud.co.ke/sitemap but its not in xml format... take a look and please help
I have this controller named Sitemap.php
<?php
class Sitemap extends Controller {
public function __construct(){
require APPROOT.'/views/inc/load_models.php';
}
public function index(){
$this->view('sitemap/index');
}
}
Also created the view index.php and uploaded to the site shown below
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
<url>
<loc>https://businessclaud.co.ke/</loc>
<lastmod>2021-06-19T02:02:46+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>
<url>
<loc>https://businessclaud.co.ke/admin/users/login</loc>
<lastmod>2021-06-19T02:02:46+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.80</priority>
</url>
enter link description here
Something is not right. Just found out an hour ago that i can see the php xml page businessclaud.co.ke/sitemap but its not in xml format... take a look and please help
I found out that since the sitemap view is in php format that is index.php what you need to do is tell the browser to treat it as xml. This is done by defining the header header("Content-type: text/xml");.
If you are facing a problem like this, go to your controller and add this line header("Content-type: text/xml");.
<?php
class Sitemap extends Controller {
public function __construct(){
// require APPROOT.'/views/inc/load_models.php';
}
public function index(){
header("Content-type: text/xml");
$this->view('sitemap/index');
}
}
And just like that, the site is ready to submit a sitemap.
Let me know how can I get "checkout/cart_sidebar" block as HTML into variable ?
I need to get it from my own magento controller
As I see "checkout/cart_sidebar" depends on "Mage_Checkout_Block_Cart_Sidebar" class
so may It is possible to get this template via some Mage:: Static Instance Methods
I tried a few ways I couldnt (
thanks
In your controller you could try something like this:
$block = $this->getLayout()->createBlock('checkout/cart_sidebar');
$block->setTemplate('checkout/cart/sidebar.phtml');
Depending on your configuration (Config -> Checkout -> Shopping Cart Sidebar), you can render the template with
$block->toHtml();
If you use a custom template, you could ignore the config value so it renders anytime.
Actions in layout xml configs are just a block method call.
The two below are equivlent
<block type = "checkout/cart_sidebar"
name = "cart_sidebar"
as = "cartExplorer"
template = "checkout/cart/sidebar.phtml"
before = "-">
<action method="addItemRender">
<type>configurable</type>
<block>checkout/cart_item_renderer_configurable</block>
<template>checkout/cart/sidebar/default.phtml</template>
</action>
<!-- Programatically create the block -->
<?php
$this->getLayout()
->createBlock('checkout/cart_sidebar', 'cart_sidebar')
->setTemplate('checkout/cart/sidebar.phtml');
->addItemRender(
'configurable',
'checkout/cart_item_renderer_configurable',
'checkout/cart/sidebar/default.phtml'
)
?>
<!-- This is if it was already created in a layout.xml file -->
<?php
$this->getLayout()
->getBlock('cart_sidebar')
->addItemRender(
'configurable',
'checkout/cart_item_renderer_configurable',
'checkout/cart/sidebar/default.phtml'
)
?>
Hope this helps!
my over all goal is to grab the articles content after they have saved it and send it though my API. It's stated that onContentAfterSave is fired after they save to the database, my database is getting updated, but nothing coming though api.
Im using Joomla! 3.2.3 Stable
Owtest is my api call, it currently has hard coded data in it.
I feel im either extending the wrong class or missing an import. code below.
<?php
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgContentHelloworld extends JPlugin
{
public function onContentAfterSave( $context, &$article, $isNew )
{
owTest();
}
}
?>
Xml Code:
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="content" method="upgrade">
<name>plg_content_helloworld</name>
<author>Keith</author>
<creationDate>March 18th, 2014</creationDate>
<copyright></copyright>
<license>GNU General Public License</license>
<authorEmail></authorEmail>
<version>1.0</version>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
</files>
</extension>
file names are helloworld.php and helloworld.xml respectfully.
what solved my problem was passing article by value and not reference
problem is self made module not working- I make my self made module in Joomla 3.0. I made a mod_products folder here we created a file called mod_products.php.
mod_products.php - code
defined('_JEXEC') or die;
require_once __DIR__ . '/helper.php';
$value = modProductsHelper::getproducts( $params );
require JModuleHelper::getLayoutPath('mod_products', $params->get('layout', 'default'));
and after it I made second file helper.php code -
class modProductsHelper{
public static function getProducts( $params ){
return 'Products';
}
}
and third one is default.php
<?php
defined('_JEXEC') or die;
if($value!='') { ?>
<ul style="margin-left: 0px;" class="clients-list slides-list slide-wrapper">
<li class="slide">
<div class="product-image"><img src="images/product3.png" width="181" height="177"></div>
</li>
</ul>
<?php } ?>
Then we install through administrator panel and gave a position to the mod_products module and display in index.php file like so:
<div class="grid_12 product_home">
<jdoc:include type="modules" name="position-3" />
</div>
But it's not being displayed on the site. Does anyone have any idea why?
Edit:mod_products.xml
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.0" client="site" method="upgrade">
<name>mod_products</name>
<author>Joomla! Project</author>
<creationDate>July 2004</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin#joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_PRODUCTS_XML_DESCRIPTION</description>
<files>
<filename module="mod_products">mod_products.php</filename>
<folder>tmpl</folder>
<filename>helper.php</filename>
<filename>mod_products.xml</filename>
</files>
<config>
</config>
</extension>
Right, I've created a small example for you. I think it might have been due to you calling the wrong module layout, not entirely sure.
Here is a link to download the module. Uninstall the current module you're using via the Joomla backend and install this:
http://www.mediafire.com/download/ucp3prv219430zl/mod_products.zip
Also, don't forget to assign the module to a menu item. That might have been the problem before
Enjoy
For me it seems your problem is module name.In some places you have used mod_product and in other places mod_products Please make sure you use only one.I will suggest you to change
require JModuleHelper::getLayoutPath('mod_products', $params->get('layout', 'default'));
to
require JModuleHelper::getLayoutPath('mod_product', $params->get('layout', 'default'));
Also check that you have published the module and also test it for all pages.
I have read several posts on stack overflow
Overriding a Magento Adminhtml template file
Magento - overriding Adminhtml block
and a couple threads on the magento forum
http://www.magentocommerce.com/boards/viewthread/21978/
However, None of these posts attempt to do what I am trying to do
I would like to override the
app/design/adminhtml/default/default/template/widget/grid.phtml
file, as this file contains a portion of html that allows anyone to export from the sales->order view.
Note: We have disabled all of the export options for this user role in the permissions->role view
The code that displays the "Export to: " -> "CSV/Excel XML" feature is included in the path I have listed above. I would like to remove that chunk of html and override the file included with Magento.
Adminhtml uses the same theming fallback as the frontend, therefore you need only declare a custom template theme for your installation in module config XML:
<stores>
<admin>
<design>
<theme>
<template>custom</template>
</theme>
</design>
</admin>
</stores>
Then you can create app/design/adminhtml/default/custom/template/widget/grid.phtml with any customizations you like, and this file will be used in preference to the one from the default/default adminhtml theme. Your solution then would be to add an ACL check in the logic which renders the export control:
<?php if($this->getExportTypes() && {ACL LOGIC}}): ?>
<td class="export a-right">
<img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/> <?php echo $this->__('Export to:') ?>
<select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
<?php foreach ($this->getExportTypes() as $_type): ?>
<option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
<?php endforeach; ?>
</select>
<?php echo $this->getExportButtonHtml() ?>
</td>
<?php endif; ?>
While this logic might be more appropriately implemented in the block class, the class rewrite system does not accommodate rewriting of parent classes, leaving you to rewrite every subclass. In this instance, obeying DRY outweighs embedding too much logic in templates. Moreover, the change is obvious and easily maintained.
Ideally the core team would have implemented this check in the Mage_Adminhtml_Block_Widget_Grid class or at least provided a public setter for the _exportTypes property, which would have made this logic a bit cleaner to implement.
It might seem the simplest solution to rewrite the block but that's more of a dirty hack than a clean solution. Class rewrites should be used very carefully and always avoided if possible. Otherwise you will quickly run into conflicts and also updating Magento gets a hell.
Usually you can change templates by a custom layout update (i.e. in your local.xml), but in this case it is a widget, which are not configured via layout XML.
So, enter observers: create a module that contains the following in its config.xml
<adminhtml>
<events>
<adminhtml_block_html_before>
<observers>
<yourmodulename_observer>
<class>yourmodulename/observer</class>
<method>changeWidgetTemplate</method>
</yourmodulename_observer>
</observers>
</adminhtml_block_html_before>
</events>
</adminhtml>
If you don't understand any of the above, read about Magento Events and Observers.
Now you will need the observer itself to actually change the template, but only for this block type:
class Your_Modulename_Observer
{
public function changeWidgetTemplate(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Widget_Grid) {
// consider getting the template name from configuration
$template = '...';
$block->setTemplate($template);
}
}
}
Magento - Override adminhtml template file
add below code to config.xml file of extension (you created)
<stores>
<admin>
<design>
<theme>
<default>default</default>
<template>rwd</template>
</theme>
</design>
</admin>
</stores>
Now create rwd folder under adminhtml/default/rwd package.
and create template and layout file as you want to override.
like we want to override order comment history.phtml file.
<root>\app\design\adminhtml\default\default\template\sales\order\view\history.phtml
<root>\app\design\adminhtml\default\rwd\template\sales\order\view\history.phtml
Template definition can be found here
class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
in
public function __construct($attributes=array())
So you need to rewrite sales grid block if you want to remove export csv from Sales Order Grid (use this guide if you don't know how http://www.magentocommerce.com/wiki/groups/174/changing_and_customizing_magento_code) and to change __construct to be like
public function __construct($attributes=array())
{
parent::__construct($attributes);
$this->setTemplate('...'); //here is your template
}