Change template after user login in joomla 1.5 - joomla

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

Related

Extbase extension bootstrapped via a TypoScript object path doesnt cache his action

I bootstrap a Extbase plugin via a TypoScript object path (USER_INT):
lib.pagefiles = USER_INT
lib.pagefiles {
userFunc = tx_extbase_core_bootstrap->run
pluginName = Pi1
extensionName = Pagefiles
controller = PageFiles
action = list
view =< plugin.tx_pagefiles.view
settings =< plugin.tx_pagefiles.settings
}
The list action of this extension isnt cached anymore now (I tested it with a print of a timestamp in the controller).
When I load the action via a front-end plugin on the page the extension caching is working correctly.
My ext_localconf.php:
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY,
'Pi1',
array(
'PageFiles' => 'list',
),
// non-cacheable actions
array(
)
);
?>
Does anyone understand whats going on here? How can I fix this problem?
The extension output is not cached, because you used a USER_INT object in your TypoScript configuration (USER_INT objects are never cached by definition).
Try using a USER object instead.

JToolbar::save() redirection

I'm going through the Joomla 2.5 tutorial to build a custom component. Now I'm facing an issue on the redirection after using JToolbar::save() or JToolBarHelper::cancel for that matter. By default Joomla wants to redirect to the default layout (from the edit layout). However I don't want it to do that. I want it to redirect back to another view. In Joomla 1.5 I would have done this through adding the function into the controller - something like
function cancel()
{
//redirects user back to blog homepage with Cancellation Message
$msg = JText::_( 'COM_BLOG_POST_CANCELLED' );
$this->setRedirect( 'index.php?option=com_jjblog&view=jjblog', $msg );
}
Now that works beautifully for the cancel function, however for save this is a much more complex thing. If I want to overwrite the url do I have to redirect the controller to the model and then write in all the code for the model interaction? Because that seems slightly excessive just for a url redirection like you would in Joomla 1.5?
Hope you have added the save toolbar code with the proper controller name like this
JToolBarHelper::save('controllerName.save');
Create a save function in appropriate controller.
Add the task in the form
Finnally make sure you have added form action withthe corresponding component name.
You can try this-
In the controller firstly you call the parent save function than redirect to url.
function save(){
parent::save();
$this->setredirect('index.php?option=com_mycomponent');
}
OK it didn't need to $this->setRedirect at all. Just needed me to change the value to
protected $view_list = 'jjBlog';
which then sets the redirects of everything back to that list view.
Source link for this is here.
Thanks for all the responses though!!
view.html.php
protected function addToolbar ()
{
JRequest::setVar ('hidemainmenu', false);
JToolBarHelper::title (JText::_ ('Configuration'), 'configuration.gif');
JToolBarHelper::save($task = 'save', $alt = 'JTOOLBAR_SAVE');
}
controller.php
public function save()
{
$mainframe = JFactory::getApplication();
$mainframe->enqueueMessage (JText::_ ('COM_SOCIALLOGIN_SETTING_SAVED'));
$this->setRedirect (JRoute::_ ('index.php', false));
}
I think you can use
global $mainframe;
$mainframe->redirect("index.php?option=com_user&task=activate&activation=".$activation);
If you are overriding joomla's default save function in your custom component like
function save( $task = 'CustomSave', $alt = 'Save' ) // or even same name Save
Inside your controller you can use the CustomSave as the task and use $mainframe for redirect.
or
$mainframe = &JFactory::getApplication();
$mainframe->redirect("index.php?option=com_user&task=activate&activation=".$activation);
Hope this may help you..

Magento Backendgrid: Click on a data entry and display its data

I used this tutorial (especially Lesson 6 and 7) to create my own backend grid for Magento: http://www.pierrefay.com/magento-developper-guide-howto-tutorial-5
Everything works fine. I can create new data entries for my grid. If I click on an entry the VarienForm is displayed again but all the text fields are empty. This seems as if Magento thinks I want to edit all the text fields. But actually I want it to display the entry data first. But it only shows empty fields.
Can anyone help me out here? Thanks a lot!
There are a lot of things that could be wrong with your implementation, but it's impossible to say without seeing your code. Nevertheless, I'm going to try. That tutorial looks fine to me, but I haven't run the code so I can't be sure. I'm inclined to think you might have just missed something. Working in grids & tabs can be particularly delicate at the best of times.
It does sound to me like it's one of two things. It sounds like either
A) Your model data is not being stored in the registry. That means the problem is in this part of the code:
<?php
class Pfay_Test_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
...
public function editAction()
{
$testId = $this->getRequest()->getParam('id');
$testModel = Mage::getModel('test/test')->load($testId);
if ($testModel->getId() || $testId == 0)
{
Mage::register('test_data', $testModel);
}
What this section of code does is 'registers' the selected model in Magento's registry. Later in the code, you'll see that it calls:
$form->setValues(Mage::registry('test_data')->getData());
to populate your form fields.
Try putting commands like these in the code above:
var_dump($testId);
die();
or
print_r($testModel);
die();
and running it again. Is $testId being set? Is $testModel being loaded? Is the if statement for the registry loading? If not, trace the problem back.
or it might also be
B) Your form is not prepopulating data because the column names are wrong.
Look where the code says:
<?php
class Pfay_Test_Block_Adminhtml_Test_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('test_form', array('legend'=>'ref information'));
$fieldset->addField('nom', 'text',
array(
'label' => 'Nom',
'class' => 'required-entry',
'required' => true,
'name' => 'nom',
)
);
You need to ensure that "nom" is in fact one of your model's attribute names. Did you change the attribute names when you created your test model and forgot to change it here? Change these values accordingly.
I hope that this helps you to solve your problem. Good luck!

getAddressesHtmlSelect() Change - Magento

I've been trying to edit the getAddressesHtmlSelect() function (found in code/core/Mage/Checkout/Block/Onepage/abstract.php) in order to enable the "new address" to display first in the dropdpown created.
I've located the place it needs to be changed in, but I can't figure out how to do that. Can anyone help? The code in question is:
$select = $this->getLayout()->createBlock('core/html_select')
->setName($type.'_address_id')
->setId($type.'-address-select')
->setClass('address-select')
->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"')
->setValue($addressId)
->setOptions($options);
$select->addOption('', Mage::helper('checkout')->__('New Address'));
return $select->getHtml();
Look for magento block rewrite.
You need to rewrite Mage_Checkout_Block_Onepage_Billing and Mage_Checkout_Block_Onepage_Shipping
Just rewrite this blocks in your custom module and define new logic for getAddressesHtmlSelect
function
To set "New address" as default one:
Assembled working sample for you.
array_unshift($options, array('value' => '', 'label'=> Mage::helper('checkout')->__('New Address')));
$select = $this->getLayout()->createBlock('core/html_select')
->setName($type.'_address_id')
->setId($type.'-address-select')
->setClass('address-select')
->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"')
->setOptions($options);
return $select->getHtml();

The url from an image via custom field (wordpress)

Am not even sure if this can be done but...
Ive added a feed from my forums to wordpress it works great but I need it to auto add the url of the image in a custom field from the images in the post (feed) first image would be fine as its only ahve a slider
Is there any way to do this?
Details
Ok I think I did not explain this very well so made a few screen shots
This is my slider at the minute with my
This is an imported post one other feed I was using
On this image you can see the custom field (which I have to fill in after every import)
Adding the image url into the custom field
and finaly a view of the slider working
This is what am trying to do (auto) so my feed from my booru / forums / 2 other of my sites and (2 other peoples) sites make my home page on a new site
Hope this explain it alot more
This uses the external Simple Pie library built into WordPress to fetch the feed, get the image url and create a new post for each item and save the image url as a custom field.
To activate the process we have to hook into wp_cron. The code below does it daily but it would probably be better to do it weekly to prevent overlap. Some overlap will probably occur so this still needs a way to check if we have already imported the image
First we need a function to save the custom field after the post has been created. This section comes from another answer I found on WordPress Answers.
Edit:
This needs to be wrapped in a plugin to schedule the cron event and the cron event was missing the action to make it fire.
Edit:
Final version below tested and it works but the feed the OP is getting is using relative url's so the domain name needs to be added somewhere in the output code.
<?php
/*
Plugin Name: Fetch The Feed Image
Version: 0.1
Plugin URI: http://c3mdigital.com
Description: Sample plugin code to fetch feed image from rss and save it in a post
Author: Chris Olbekson
Author URI: http://c3mdigital.com
License: Unlicense For more information, please refer to <http://unlicense.org/>
*/
//Register the cron event on plugin activation and remove it on deactivation
register_activation_hook(__FILE__, 'c3m_activation_hook');
register_deactivation_hook(__FILE__, 'c3m_deactivation_hook');
add_action( 'c3m_scheduled_event', 'create_rss_feed_image_post');
function c3m_activation_hook() {
wp_schedule_event(time(), 'weekly', 'c3m_scheduled_event');
}
function c3m_deactivation_hook() {
wp_clear_scheduled_hook('c3m_scheduled_event');
}
function create_rss_feed_image_post() {
if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php'); // include the required file
$feed = fetch_feed('http://animelon.com/booru/rss/images'); // specify the source feed
}
foreach ($feed->get_items() as $item) :
// global $user_ID;
$new_post = array(
'post_title' => $item->get_title(),
'post_status' => 'published',
'post_date' => date('Y-m-d H:i:s'),
//'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
if ($enclosure = $item->get_enclosure() )
update_post_meta( $post_id, 'feed_image_url', $enclosure->get_link() );
endforeach;
}

Resources