I Assigned my Component profile page into Joomla Menu Item. when i access the particular menu Item. Its Display following Error.
Your question seem to indicate that the component is working when accessing it directly with an url, but not when accessed as a menu item, is this so? In that case there must be something wrong with the menu link. If accessing the url directly after the menu link is created does not work, then some option from the menu must affect how your component is working. Try identifying where the access forbidden exception is raised. Try f.ex to add something like
print_r($option); die('Exit execution');
in relevant functions in the search model in your component, or similar in the controller. This will help reveal where the error is.
Check the menu item if it can be accessed by public, registered or special.
After checking your script I have found out that there are several mistakes that you have made. I cannot point out each mistake. To give you a way forward I would suggest you to make these change in truematrimony.php file
REPLACE THIS
// import joomla controller library
jimport('joomla.application.component.controller');
$doc = JFactory::getDocument();
FOFDispatcher::getTmpInstance('com_truematrimony')->dispatch();
TO
// import joomla controller library
jimport('joomla.application.component.controller');
// Initialize the controller
$controller = JControllerLegacy::getInstance('Truematrimony');
// Perform the Request task
$controller->execute(JFactory::getApplication()->input->get('task', null, 'default', 'cmd'));
$controller->redirect();
Related
I use dnadesign/silverstripe-elemental 2.x-dev, and Silverstripe 4.0.1.
I created a module for page to hold all pages. This is how i added the extension to HomePage.
XYPage\Model\HomePage:
extensions:
- DNADesign\Elemental\Extensions\ElementalPageExtension
This is my HomePageController:
namespace XYpage\Controller;
use PageController;
class HomePageController extends PageController
{
}
This is my HomePageModel:
namespace XYpage\Model;
use Page;
use XYpage\Controller\HomePageController;
class HomePage extends Page
{
private static $table_name = 'HomePage';
/**
* As our controller resides in a different namespace we have to
overwrite this method
*
* #return string
*/
public function getControllerName()
{
return HomePageController::class;
}
}
I changed the template variable to $ElementalArea. I see the expected UI in the BackEnd.
Now if i save an single element in the backend i always get redirected into the front-end to the 404 Page.
When i switch back to the Backend the element is linked to the page.
If i fill in content to the WYSIWYG editor on the Content Element and save it the content gets displayed on the page in the frontend.
If i try to edit that element misses the WYSIWYG editor for the content.
I tried hard to fix this, red the docs but i donĀ“t see what i did wrong.
There is an issue with BetterButtons & DNADesign Elemental.
Just add this to disable BetterButtons for ElementContent in the meantime.
DNADesign\Elemental\Models\ElementContent:
better_buttons_enabled: false
You have two problems that I can see immediately:
1: Your YAML configuration is referencing XYPage\HomePage, where the class's namespace is actually XYPage\Model\HomePage. I suspect this is actually an error in your example rather than your actual project, since you say that the elemental editor is working in the CMS.
2: Your getControllerName() method is returning HomePageController::class which isn't imported in the class, so it will be resolving to the same namespace as the model (XYPage\Model\HomePageController). While this is the default/expected location for SiteTree controllers, overloading this code means it's all on you! Add use XYPage\Controller\HomePageController; to your class definition.
After a lot of debugging i found out what caused this some of that behavior. In my case one problem was that i used unclecheese/silverstripe-gridfield-betterbuttons with elemental.
The next Problem is a react error:
I know there are several similar topics around but I read and tried most of them but still can't figure out how to do this.
I have a written a component in Joomla 2.5 and it works so far. I have different views and I can load the views using the controller.php.
One of the views shows a table out of my data base (data about teams).
Now I'd like to have another layout of the same view which would display the data base table as a form so can change the content.
That's the file structure:
views/
- teams/
- - tmpl/
- - - default.php
- - - modify.php
- - view.html.php
That's out of the view.html.php file:
...
// Overwriting JView display method
function display($tpl = null) {
...
$this->setLayout('modify');
echo $this->getLayout();
// Display the view
parent::display($tpl);
}
I tried different combinations of setLayout, $tpl = ..., default_modify.php, etc.
but I always either get the default layout or some error like 'can't find layout modify'
I load the site with .../index.php?option=com_test&task=updateTeams
And the controller.php looks like this:
function updateTeams(){
$model = $this->getModel('teams');
$view = $this->getView('teams','html');
$view->setModel($model);
$view->display();
}
I had a similar problem, I created some kind of user profile view and wanted them to be able to edit the fields without having to create a new model for it (would have similar functions, hate redundancy...). What worked for me is to simply call the layout like this:
index.php?option=com_mycomponent&view=myview&layout=edit ("edit" would be "modify" in your case)
To do this I didn't touch the view.html.php (well I did at first but I didn't have to.). And you don't need to use the controller either. If you want to load the modify view, just add a button to your regular view linking to the modify layout. No need to change anything else.
I happen to have written a blog article about it, check it out if you want: http://violetfortytwo.blogspot.de/2012/11/joomla-25-multiple-views-one-model.html
Hope this helps.
Ok this is the problem .. you don't want another layout, you want a new MVC triad that is based on forms rather than rendering. So if you look at any of the core content components you will see in the backend they have a mvc for say ... contacts and one for contact and contact is the editor. If in the front end you will notice that com_content and com_weblinks have mvc for artice/weblink and then separate ones for editing.
You need a really different model and layout and set of actions for editng than for just rendering.
Old topic, but it might still help.
It seems that when one wants to change the layout, the $tpl must not be included in the display() or must be null.
So the previous code would be:
function display($tpl = null) {
/* ... */
$this->setLayout('modify');
// Display the view without the $tpl (or be sure it is null)
parent::display();
}
I'm making a custom module for PyroCMS, and I want to get the section menu working with regard to applying the current class. The CMS php, which I don't want to change looks like this:
<li class="<?php if ($name === $active_section) echo 'current' ?>">
When I'm viewing /admin/courses/ this is correct, and the first navigation element has the class, current.
$name is taken from the language file, as set up in details.php.
$active_section is taken from the view, and is equal to
$this->_ci_cached_vars['active_section']
However when I view /admin/courses/chapters/, 'courses' is still determined by the system to be the current section, so the navigation is confusing.
What I need is a way of changing the value of $active_session in the view acording to which function of the controller (index, chapters or pages) is being used.
I've tried changing the value of $this->_ci_cached_vars['active_section'] in each controller function, but that doesn't work. Any ideas?
I'm sure there's something basic I'm missing completely.
Got it.
I'm using multiple methods in one controller, and the 'protected $section = 'courses'; line, which happens before the index method, was setting the section for everything.
It couldn't be set a second time within another method, but there is a way to define a section within a method.
$this->template->active_section = 'section';
Starting my method as follows gave me what I wanted.
public function chapters(){
//Set active section
$this->template->active_section = 'chapters';
...
}
The Magento backend allows you to disable module output per site. I've done some Google searches but can't figure out how to grab this value through my code. Basically when my module's output is disabled that works just fine. But I've discovered (the hard way) that Magento doesn't prevent the module from loading per-site.
Because I'm extending some core classes, some constructors are still being executed. My thought is to check if the module output is disabled. If so, have my constructor call the parent's constructor. If the module output is enabled, proceed with my custom code.
I just can't figure out how to grab this value for the current site (I am multi-sited, BTW). Ideally it would be something like this:
$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');
Basically have a single line that fetches the current site's value (or the default, if not specified for the current site).
Any help would be greatly appreciated!
EDIT: I found the table core_config_data, which appears to store this information. I could manually query it if I had to, but I feel like Magento would have something built-in to return the current store's value, falling back to the default value.
It is a standard config setting, so accessing it should be no different than accessing any other config setting. You just need to know what is the path to this value. Analysing the DB I believe this should do the trick:
Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');
The other option is that the Mage_Core_Helper_Abstract has an isModuleEnabled($moduleName = null) method, which means that you should be able to call:
Mage::helper('core/data')->isModuleEnabled('Namespace_Module')
There is also a isModuleOutputEnabled() method. Looking at the code, these don't seem to be filtered by store/view, whereas #silvo's method is.
<?php
public function mycontrollerAction()
{
$moduleName = 'Namespace_Modulename';//eg Mage_Cms
if(Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true'))
{
echo "Module Enable";
}
else
{
echo "Module Disable";
}
}
?>
I'm trying to create a widget within the module and then load that widget from 'outside' of the module. More particularly I'm using user module written by someone else. I don't want to have a separate page for displaying a login form, therefore I tried to make a CPortlet/widget (confusion) displaying the login form. Basically, I've moved the code from LoginController into that widget. Then I try to display the widget on some random page by
<?php $this->widget('user.components.LoginForm'); ?>
However, I get an error
CWebApplication does not have a method named "encrypting".
in UserIdentity class in this line:
else if(Yii::app()->controller->module->encrypting($this->password)!==$user->password)
This happens, because I'm basically trying to execute this code within context of the app and not the module. Thus the "Yii::app()->controller->module" trick doesn't really work as expected.
What am I doing wrong:-\
Is there a better way to achieve this. I.e. display that login form in some other page, which is normally displayed by accessing login controller within user module (user/login) or is a widget the right way of doing it?
Thanks.
The quick solution
Ok, so I simply ended up doing
Yii::app()->getModule('user')->encrypting($this->password)
instead of
Yii::app()->controller->module->encrypting($this->password)
Notice that now the module must be called 'user' in the main config, but I think this allows for more flexibility. I.e. we're not bound to only use module functionality within the module.
Additional insight on displaying widget outside of the module scope
After playing more with it that's what I did. In the UserModule.php I've created a method
public static function id() {
return 'user';
}
Then everywhere where I need the module I use
Yii::app()->getModule(UserModule::id())->encrypting($this->password)
I don't like having many imports related to the module like:
'application.modules.user.models.*',
'application.modules.user.components.*',
Because we already have those imports in the UserModule.php:
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'user.models.*',
'user.components.*',
));
}
Therefore whenever you know that some piece of functionality will be used outside of the module it's important to make sure the module is loaded. For example, in the LoginForm widget that I am trying to display NOT in one of the module controllers, I have this line of code:
$model = new UserLogin;
However, UserLogin is a model inside of the User module, and in order to be able to autoload this model we first have to make sure the module was initialised:
$module = Yii::app()->getModule(UserModule::id());
$model = new UserLogin;
I hope this will be helpful if you were stuck with the whole modules concept the way I was.
http://www.yiiframework.com/forum/index.php?/topic/6449-access-another-modules-model/ was useful but hard to find =)
You better move that encrypting() into a MyUserIdentiy class which extends CUserIdentity. Whatever the code you take to use, they putting the method in controller is a bad idea and as a result you cannot reuse that code.
The login form should still post to User/Login controller but I guess they use Yii's standard login code and you might want to modify it to use the MyUserIdentity.