JParameter showing error - joomla

I have used the below code for Joomla 1.5 & 2.5 but it is not supporting joomla 3
$pluginParams = new JParameter( $plugin->params );
Instead of i have used the below code in joomla 3
$params = new JInput();
$pluginParams = $params->get('params');
If i use the joomla 3, it conflicting with article title, content-page navigation and also with K2 component.
Is there any solution to get the plugin params in joomla3.

JParameter was deprecated for the whole lifetime of the 1.6-2.5 series and removed in Joomla 3. You should be using JForm in both.

Related

Captcha Custom Form in Joomla 2.5

after many hours of trying and searching to solve an issue with captcha issue and several faild attempts to fix the problem I decide to ask for your help, I have a web site on Joomla 2.5 I have a custom register form for new users and I want to add a captcha mechanism, where here what I made (i found it here in stackoverflow but i have some qusetions).
So far I made the followings:
1)I enabled the capcha-recaptcha plugin and I enter private key and site key from google captcha
2)I set captcha-Recaptcha to Default captcha at global configuration
3)In my file template\mytemplate\html\mod_login\default.php
I enter the following code which I found here in stackoverflow
//php code
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit','dynamic_recaptcha_1');
//html code inside form tag
<div id="dynamic_recaptcha_1"></div>
So far so good it appears the captcha image and entry box but when I press submit button I receive Invalid token
I suspect that it has something to do with the following part of code which it should validate/proccess the form
$post = JRequest::get('post');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
die('Invalid Captcha');
}
in joomla in which file I should insert the validation code? I have tried in submit button at : template\mytemplate\html\mod_login\default.php
but nothing, I have tried also at com_users\controllers\registrattion.php still nothing any ideas where I should insert this part of code? in order to make it work?
Thnks in advance for your time!!
Regards,
Jim
EDITED ANSWER
Try this code below from https://forum.joomla.org/viewtopic.php?t=833213
$app = JFactory::getApplication();
$captchaResponse = JRequest::get('recaptcha_response_field');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$captchaResponse);
if(!$res[0])
{
// Invalid captcha
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
return false;
}
ORIGINAL ANSWER
Make sure you are using newest version of the 2.5 series. The original recaptcha plugin won't work because Google changed their API script location from recaptcha.net to google.com/recaptcha . You can open the recaptcha files to do a quick check.

$mainframe->close() Joomla 2.5

In Joomla 1.5 when I like to call AJAX, I add function in the controller like so
global $mainframe;
$idContact = JRequest::getVar('idContact');
$modelContact = $this->getModel('clientcontact');
if($modelContact->delete($idContact))
echo "1";
else
echo "0";
$mainframe->close();
And the controler return 1 or 0 (I dont need to use the raw or anthing else just tmpl=component in the URL)
In the 2.5 I have an error wiht $mainframe->close();
I dont like to use the raw or modal layout
global $mainframe;
Was deprecated in 1.6 and is not available in Joomla 2.5 you should read the Adapting a Joomla 1.5 extension to Joomla 2.5 article on the Joomla Doc's website.
If you're doing it the lazy way, then you can simply replace:
global $mainframe;
With:
$mainframe = JFactory::getApplication();
throughout your extension.
In addition the $option global is gone.
You may also want to bookmark the Developers portal on Joomla Doc's.

How can integrate html template in codeigniter

I'm new to codeigniter. please tell me how can I integrate or install a html theme/template in codeigniter ? (my css folder path=news/css and application folder path=news/application where news is my main folder)
-thanks.
This is a very simple, very powerful way to do templates in codeigniter that is also very flexible.
http://news.dice.com/2013/02/18/how-to-build-a-to-do-app-with-codeigniter/
ignore the title, most of the lesson is about setting up templates in CI.
Note that i was first exposed to this method from a jeffrey way CI tutorial on net.tutsplus.com
All of them are worth checking out: http://net.tutsplus.com/sessions/codeigniter-from-scratch/
edit -- ok this is good enough addition to post. So in the tutorial, on the template.php page, you will see
$this->load->view($maincontent);
which is cool. but this is much better:
// load your header views
$templatefolder = 'beta/';
if(isset($content01))
$this->load->view($templatefolder.$content01);
if(isset($content02))
$this->load->view($templatefolder.$content02);
if(isset($content03))
$this->load->view($templatefolder.$content03);
// load your footer views
so instead of calling the view "maincontent", i've put in references to $content1, $content2, etc. Because we are doing if isset none of them are required. that way you can easily send more then one view file to the template. Or none at all if you are just showing a message, etc. Also notice that we have $templatefolder - that way you can easily reuse the template file for other site templates, even with the same content.
in your controller (similar to tutorial) it would be
$data['content01'] = 'codeigniterrawks';
$data['content02'] = 'mypetlion';
// beta template
$this->load->view( 'template_beta', $data );
note how easy it is if i want to bring in those same view files into a different template
$data['content01'] = 'codeigniterrawks';
$data['content02'] = 'mypetlion';
// alpha template
$this->load->view( 'template_alpha', $data );
I ran into this exact question about a week ago, this guide really helped me:
http://net.tutsplus.com/tutorials/php/an-introduction-to-views-templating-in-codeigniter/
To do the CSS url's, I added "uri" to my libraries in config/autoload.php (so it looks like this:
$autoload['libraries'] = array('uri', 'database');)
" type="text/css" media="screen" />
the base_url function automatically return whatever the base url of your site is, ie
http://localhost/news/
with the argument appended to the end.
The reason behind this is that if/when you ever need to migrate servers, you just change the base_url in the config file and it automatically updates across all of your templates and sources.
Try this,
I'm using this and it's very powerful.
https://github.com/philsturgeon/codeigniter-template

Place certain article anywhere in joomla template

Is it possible in Joomla to place a certain article in a template, additionally to the normal content? I want the article to show up on every page.
You can simply take it from the databse and print its content. In the template, where you want to show the article, write this:
$id=/*Id of the article to show*/;
$db=&JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id=$id");
$item=$db->loadObject();
echo $item->introtext;
UPDATE: ENABLE PLUGINS
I can't find where i've used that code and i can't copy-paste it, so i try to write it again by looking at the view.html.php of the com_content:
JPluginHelper::importPlugin('content');
$dispatcher =& JDispatcher::getInstance();
$params = &$mainframe->getParams();
$dispatcher->trigger('onPrepareContent', array (&$item, &$params, 0));
//The last line triggers the onPrepareContent event, so if it does not work maybe you need other events, so try with onAfterDisplayTitle, onBeforeDisplayContent or onAfterDisplayContent
Have you seen this? http://extensions.joomla.org/extensions/news-display/content-embed/7528
It allows you to place any article as a module on your Joomla site. And with modules you can have them displayed site wide.

Joomla: How to change template on a specific article

Is there a way to change the template on a specific article only?
Note that it should work without linking the article to any menu.
If you want the template override not to depend on the menu position than the standard joomla way of assigning a different template to a menu will not work. You will need to get your hands dirty and write some custom code. You will need to use the article_id as a trigger for template switch.
I did something like that at work but don't remember now how exactly this is achieved. I will post my code here as soon as I locate it.
EDIT: Found the code :)
You need to edit the file /includes/application.php, specifically the getTemplate() method. At the end of this method, just before:
// Fallback template
if (!file_exists(JPATH_THEMES.DS.$template.DS.'index.php')) {
$template = 'rhuk_milkyway';
}
you can add your condition for applying a custom template, like so:
//CUSTOM TEMPLATE FOR THE ARTICLE 13
if (JRequest::getVar('id')=='13' && JRequest::getVar('option')=='com_content') {
$template = $custom_template_name;
}
This will apply the custom template which name is inside the $custom_template_name to article with id=13. You can also use it to apply a different template to components, like I did with simplecaddy:
//TEMPLATE FOR SIMPLECADDY
if (JRequest::getVar('option')=='com_caddy'){
$template = 'shop';
}
You should really try to stay away from hard coding anything in to the template if it can be avoided. Not sure why you would specify that the article not be linked from a menu. The easiest way to accomplish this without having to write and code is to create a new menu, then add a menu item that links to the article you want to specify the template for. You don't have to put the menu in a module anywhere so it will never show up on the site, but it will show up in the menu assignment in the template manager.
You can do this with single articles, categories, sections, or even components. As long as you have a menu link to associate the template to. I always create an Admin only menu to put links that are needed to run the site, but do not need to be accessed by users.
As Brent said, avoid the temptation to modify core Joomla code! Doing this will likely stop you from doing Joomla upgrades 'cos you know it's going to break the core changes that you made.
Apart from the "hidden menu item" technique (which is useful but can break SEF URLs in some situations), a useful tool is Chameleon. This allows you to select specific articles/categories/sections (plus things like browser type, user group, component, whatever) and use these to trigger a certain template.
Though this is an old post, I thought I'd share my thoughts: You can easily change template on a single article, by implementing the onAfterInitialize() - function in a system plugin. No need to modify the Joomla core.
This works for Joomla 1.5, but should also work in 2.5:
function onAfterInitialise(){
if(true){ // f.ex. test for article ID or whatever
JRequest::setVar('template', 'beez'); // change template
}
}
In joomla 3.x versions, url-parameters are handled differently. The following was tested in joomla 3.4.8:
public function onAfterInitialise()
{
$app=JFactory::getApplication();
if(true){ // f.ex. test for article ID or whatever
$app->input->set('template', 'beez3');
}
}
More on writing plugins for Joomla here

Resources