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.
Related
I would like to add 2 custom attributes after the product name EVERYWHERE in the magento 2 shop.
Like "Productname Attribute1 Attribute2"
Is this possible and how? Do i need to modify every page or is there a way to act directly on the product name rendering for the whole system?
thanks
Fot that you have to create extension. Please check my code
Create folder in app/code/Magenest
Create sub folder in app/code/Magenest/Sample
Now create registration.php with following code
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magenest_Sample',
__DIR__
);
Create etc folder in app/code/Magenest/Sample/
Create module.xml in etc folder with following code
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magenest_Sample" setup_version="2.0.0">
</module></config>
Create folder in frontend in app/code/Magenest/Sample/etc/
Create a file di.xml file in app/code/Magenest/Sample/etc/frontend with following code
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Model\Product" type="Magenest\Sample\Model\Product"/>
</config>
Now create a Model folder in app/Magenest/Sample/
Create Product.php in Model folder with following code
<?php
namespace Magenest\Sample\Model;
class Product extends \Magento\Catalog\Model\Product
{
public function getName()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($this->_getData('entity_id'));
$myattribute = $product->getResource()->getAttribute('putyourcustomattribute')->getFrontend()->getValue($product);
$changeNamebyPreference = $this->_getData('name') . ' '. $myattribute;
return $changeNamebyPreference;
}
}
How can I use composer to install dompdf, and load this into a controller class in opencart 3.
I have tried to use composer require dompdf... however this doesn't work, I'm not sure what directory this needs to be run in
In your composer.json file, add the Dompdf package:
{
"require": {
"dompdf/dompdf": "dev-master"
}
}
And then run: composer update
To use DOMPDF in an opencart controller, all you have to do is:
<?php
class ControllerExampleEmail extends Controller {
public function index() {
$dompdf = new DOMPDF();
}
}
It's auto-loaded by OpenCart itself.
Only really posting this as an answer to get the formatting, but I was just looking at exactly the same thing (adding DOMPDF to OpenCart 3) and (having already done the composer bit) have gotten this far (which will spit out a PDF):
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>DOMPDF Test</name>
<code>dompdftest</code>
<version>3.0.3x</version>
<author>TH</author>
<link></link>
<file path="system/library/response.php">
<operation error="abort">
<comment>Use the class</comment>
<search><![CDATA[class Response {]]></search>
<add position="before"><![CDATA[
use Dompdf\Dompdf;
]]></add>
</operation>
<operation error="abort">
<comment>Output to PDF instead of HTML</comment>
<search><![CDATA[private $output;]]></search>
<add position="after"><![CDATA[
// TH
public function writePDF($input,$filename) {
$dompdf = new Dompdf();
$dompdf->loadHtml($input);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream($filename);
}
// /TH
]]></add>
</operation>
</file>
</modification>
Have only tested this insofar as it spits out a PDF, it could well be wrong/not the best way to do it.
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.
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.