Somehow the Joomla 3 method of setting the view for redirecton is not the same as the deprecated way.
Deprecated:
JRequest::setVar( 'view', 'objects' );
Joomla 3:
JFactory::getApplication()->input->set( 'view', 'objects');
The redirections does not work with the new version (joomla3). Why?
The below is how to redirect in joomla 3
$app = JFactory::getApplication();
$app->redirect(URL);
Related
I am using LengthAwarePaginator class to "transform" collection into the paginator object. Everything works like a charm, but I need necessarily to change pagination page name. When i use setPageName() method- the page name inside url changes from default "page" to whatever I need to, but pagination links are not working at all- by clicking, the next page contents don't appear, even the url has its custom page name for pagination.
I read everywhere that this was bug before, but now its claimed it is fixed- although it gives the same bug as before this Laravel fix somewhere at v. 5.0.
PS: I need to do this by setPageName method.
PS2: If this is a bug again, why to not solve it if we found out.
Here is my code:
Controller
$currentPage=LengthAwarePaginator::resolveCurrentPage()-1;
perPage=1;
// $items is collection variable
$currentPageBlogResults = $items->slice($currentPage * $perPage, $perPage)->all();
$items= new LengthAwarePaginator($currentPageBlogResults, count($items), $perPage);
$items->setPageName('special');
$items->setPath('main-category');
View
#foreach($items as $items)
.....
#endforeach
{{$items->links()}}
It's not a bug (I guess). You're resolving current page with LengthAwarePaginator::resolveCurrentPage() but it has own page name (defaults to "page"). You have two options:
$currentPage = LengthAwarePaginator::resolveCurrentPage('special') - 1;
or
LengthAwarePaginator::currentPageResolver(function () {
return 'special';
});
Is there a way to user smarty2 instead of smarty3 in Prestashop 1.5 ? I have updated from 1.2.5 and the theme is ruined.Thanks
Maybe try the Backward Compatility feature of Smarty.
In the file "/config/smarty.config.inc.php", replace :
require_once(_PS_SMARTY_DIR_.'Smarty.class.php');
global $smarty;
$smarty = new Smarty();
by
require_once(_PS_SMARTY_DIR_.'SmartyBC.class.php');
global $smarty;
$smarty = new SmartyBC();
Can anyone please help me with the process flow through which the Joomla Itemid parameter ends up being the highlighted menu item?
I have embedded a 3rd party application in Joomla and by temporarily changing the php environment within the application.
I am able to get joomla html and insert the 3rd party html by replacing a token.
Simplified Code:
if ($_SERVER['REQUEST_METHOD'] == 'GET' ) {
$_SERVER['REQUEST_METHOD'] = '';
}
$_SERVER['REQUEST_URI'] = '/joomla/index.php?view=mycom&option=com_mycom&Itemid=103';
$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = '/joomla/index.php';
$_SERVER['QUERY_STRING'] = 'view=mycom&option=com_mycom&Itemid=103';
ob_start();
require_once '/joomla/index.php';
$joomlaHTML = ob_get_clean();
echo str_replace($replacementToken, $thirdPartyHTML, $joomlaHTML);
In v1.5.x, the menu item with ID 103 is properly highlighted but in v2.5.6, it isn't and the Home item is always highlighted. I think it used to be highlighted correctly in v1.6.x and earlier versions of 2.5.x as well but not sure.
I wanted to find how the process flows (where this is set) so I can see what tweaks I need to make.
DELETED WRONG INFO
Thanks Dayo! you saved my day with this:
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
I don't fully understand the breadcrumb part, but I managed to get it working by editing my component's controller.php to read:
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
// force fix the breadcrumb
$app = JFactory::getApplication('site');
$pathway =& $app->getPathway();
$bcrumbs = &JPathway::getInstance('site');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* MyCom Component Controller
*/
class MyComController extends JController
{
}
Look in the following File
Check the
/modules/mod_menu/mod_menu.php
File and you will see two functions has been called "getActive" and "getDefault"
Which can be find in following file
/libraries/joomla/application/menu.php
I think it can be customized easily now
I'm trying to integrate a php file inside an aplication that gives users the posibility to register an account. This account has to be registered inside a magento store.
This is what i have to this momment:
<?php
require_once '../../../app/Mage.php';
umask(0);
Mage::app('default');
Mage::app()->getTranslator()->init('frontend');
$session = Mage::getSingleton('core/session', array('name' => 'frontend'));
// get layout object
$layout = Mage::getSingleton('core/layout');
//get block object
$block = $layout->createBlock('core/template');
//print_r(get_class_methods(get_class($block))); <- use for seeing classes
$block = $block->setTemplate('customer/form/register.phtml')->renderView();
echo $block;
?>
This code renders the registration form but stops when he is showing the input fields. I tried with "mini.login.phtml" and it renderes correctly. I'm not very good at Magento, or english. I can provide any other information if necessary.
Any help will be appreciated!
Regards
You are using the wrong block type when dynamically creating the block. Try using this:
createBlock('customer/form_register')
Anybody ever tried to change joomla 1.5 template in code? Don't know how to do it on current version. I just wanted to change the template after the user login.
So, i wrote code like this :
$mainframe->setTemplate('newtemplate');
But it doesn't works. WHen i see the joomla application.php, whoops, there is no setTemplate function there, but it used to be there before 1.5 (based on my search on the web).
Anyone know how to do it?
Update :
seems that we can set user state and just read that user state, then render. But I don't know where joomla render the template, since I put a code in library/joomla/application.php, insite render(), but it didn't get executed. This is what i did :
function render()
{
$params = array(
'template' => $this->getTemplate(),
'file' => 'index.php',
'directory' => JPATH_THEMES
);
// I added this code, where i set the user state $option.template somewhere else
$template = $mainframe->getUserState( "$option.template", 'FoxySales01VIP' );
if(!empty($template)){
$params['template'] = $template;
}
$document =& JFactory::getDocument();
$data = $document->render($this->getCfg('caching'), $params );
JResponse::setBody($data);
}
Never mind, i solved it.
Just change the code in core library (JDocument Class) to read the template from session, works fine.
Thanks