Joomla 3.x onContentAfterSave not triggering - joomla

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

Related

CodeIgniter Sitemap problem view not in xml format

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.

How to add SEO plugin in Codeigniter

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.

Module not working in joomla 3.0

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.

SimpleXML (Zend_Config_Xml actually) and foreach : which tag am I iterating?

I'm implementing a little event manager in order to use the Observer pattern. To subscribe my observers to my events, I'm using the following xml file :
<?xml version="1.0" encoding="UTF-8"?>
<configData>
<subscriptions>
<subscription>
<eventName>event_name</eventName>
<class>My_Observer_Class</class>
<function>myFunction</function>
</subscription>
<subscription>
<eventName>other_event_name</eventName>
<class>My_Observer_Otherclass</class>
<function>myOtherFunction</function>
</subscription>
</subscriptions>
</configData>
I'm using a foreach to loop on the subscriptions :
foreach($subscriptions->subscription as $subscription) {
/* using $subscription->eventName etc... */
}
And everything is ok, each $subscription item has it's eventName etc...
But here comes my problem :
<?xml version="1.0" encoding="UTF-8"?>
<configData>
<subscriptions>
<subscription>
<eventName>event_name</eventName>
<class>My_Observer_Class</class>
<function>myFunction</function>
</subscription>
</subscriptions>
</configData>
Here I have only one <subscription> node. And my foreach loops on the subscription children !
To solve this problem, I'd like to know how I can check if the xml file contains several <subscription> tags, or just one...
Any help will be appreciated :)
Edit : Is there a way to use xpath with my Zend_Config_Xml object ?
You can use Xpath.
Please try below code, i have tested it with both of sample XML's you provided.
<?php
$subscriptions = simplexml_load_file('test.xml');
$scTag = $subscriptions->xpath("//subscription");
foreach($scTag as $subscription) {
echo $subscription->eventName;
/* using $subscription->eventName etc... */
}
?>
hope this help !
Just to clarify, this is an issue with Zend_Config_XML which is not present in PHP's native SimpleXML.
Given your second example as $xml, I can run the following and get the word 'subscription' as expected:
$configData = simplexml_load_string($xml);
foreach($configData->subscriptions->subscription as $subscription)
{
echo $subscription->getName();
}

Eclipse Contextual Help

Now can I register contextual help in an Eclipse WizardDialog/Editor.
1) I created a help_contexts.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
<context id="my.plugin.help.general" >
<description>test</description>
<topic label="test" href="http://domain.com/help.html"/>
</context>
</contexts>
2) I referenced this file in my plugin.xml
<extension
point="org.eclipse.help.contexts">
<contexts file="help_contexts.xml" plugin="my.plugin.MainEditor">
</contexts>
</extension>
3) I added a line in my build.properties to include this file in the bin directory (bin.includes = help_contexts.xml, ... )
4) When running my GEF-based plugin, I see "No match found for "my.plugin.MainEditor"" under dynamic help.
I know I need to create something like this somewhere, but I don't know where to set this up for my WizardDialog or at least for my whole editor:
public void createPartControl(Composite parent) {
...
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
"my.plugin.help.general");
}
Note: This question originally contained two questions. I have removed the first (unanswered part) to be posted elsewhere.
Here is how you do it:
1) I created a help_contexts.xml file. Don't have periods in the context id. Don't include your plugin name in there.
<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
<context id="help_general" >
<description>test</description>
<topic label="test" href="http://domain.com/help.html"/>
</context>
</contexts>
2) I referenced this file in my plugin.xml Don't include the plugin-id if you are referencing your own plugin.
<extension
point="org.eclipse.help.contexts">
<contexts file="help_contexts.xml">
</contexts>
</extension>
3) I added a line in my build.properties to include this file in the bin directory (bin.includes = help_contexts.xml, ... ). Note your Bundle-SymbolicName in your Manifest.MF (also visible in your plugin.xml editor). Example: my.plugin
4) Set the context id in the WizardPage (credit goes to #VonC)
public class MyWizardPage extends WizardPage
public void createControl(Composite parent) {
PlatformUI.getWorkbench.getHelpSystem.setHelp(parent, "my.plugin.help_general");
}
}
For the main question, I am not sure about your setHelp second parameter. See this thread:
In the method call
PlatformUI.getWorkbench().getHelpSystem().setHelp()
second parameter is the contextID.
It should be prefixed with the pluginID like : "pluginID.contextID".
Now I was not sure where to find the plug-in ID for my plug-in.
So I used the value of this property : Bundle-Name Bundle-Symbolic-Name from MANIFEST.MF as the plug-in ID.
Now it works.
For the sidenote (help for WizardDialog), this thread might help (from David Kyle
and his blog "Eclipse RCP"):
We set the context id in our wizard page.
public class MyWizardPage extends WizardPage
public void createControl(Composite parent) {
PlatformUI.getWorkbench.getHelpSystem.setHelp(parent,
MyPluginActivator.ID + ".mycontexthelpid");
}
}
and we set help for the wizard dialog.
WizardDialog dialog = new WizardDialog(.....);
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
"mycontexthelp.id");
We don't override performHelp().
As for the help context id. Define a context xml file in your plugin.
<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
<context id="mycontexthelpid" >
<description>My wizard help.</description>
<topic label="Wizard help" href="reference/wizard/help.xhtml"/>
</context>
</contexts>
in your plugin
<plugin>
<extension point="org.eclipse.help.contexts">
<contexts file="mywizard.xml" plugin="com.mypluginid"/>
</extension>
</plugin>
A common problem is messing up the plugin and context help ids. You can set
a couple of break points to see which context id is being requested.

Resources