We add a menu or contact link
Error
Latest 3.7.x branch
This plugins only exist in 3.7.x
pinging @infograf768 @brianteeman @zero-24
Labels |
Added:
?
|
Status | New | ⇒ | Confirmed |
Confirmed
Category | ⇒ | Plugins |
release blocker
I tried to solve the issue for contacts by proxying as should.
I had to register once the admin modal though and still get this fatal error
Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/370/infograf768/administrator/components/com_contact/views/contacts/tmpl/modal.php on line 21
This is the code I used.
diff --git a/administrator/components/com_contact/views/contacts/tmpl/modal.php b/administrator/components/com_contact/views/contacts/tmpl/modal.php
index e9a8138..1e2f493 100644
--- a/administrator/components/com_contact/views/contacts/tmpl/modal.php
+++ b/administrator/components/com_contact/views/contacts/tmpl/modal.php
@@ -24,4 +24,9 @@
$app = JFactory::getApplication();
+if ($app->isSite())
+{
+ JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
+}
+
$function = $app->input->getCmd('function', 'jSelectContact');
$listOrder = $this->escape($this->state->get('list.ordering'));
diff --git a/components/com_contact/contact.php b/components/com_contact/contact.php
index a119f16..e68d2b8 100644
--- a/components/com_contact/contact.php
+++ b/components/com_contact/contact.php
@@ -12,5 +12,13 @@
JLoader::register('ContactHelperRoute', JPATH_COMPONENT . '/helpers/route.php');
+$input = JFactory::getApplication()->input;
+
+if ($input->get('view') === 'contacts' && $input->get('layout') === 'modal')
+{
+ $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
+ require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';
+}
+
$controller = JControllerLegacy::getInstance('Contact');
-$controller->execute(JFactory::getApplication()->input->get('task'));
+$controller->execute($input->get('task'));
$controller->redirect();
diff --git a/components/com_contact/controller.php b/components/com_contact/controller.php
index de91f09..ac78e1d 100644
--- a/components/com_contact/controller.php
+++ b/components/com_contact/controller.php
@@ -18,4 +18,27 @@
{
/**
+ * Constructor.
+ *
+ * @param array $config An optional associative array of configuration settings.
+ * Recognized key values include 'name', 'default_task', 'model_path', and
+ * 'view_path' (this list is not meant to be comprehensive).
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function __construct($config = array())
+ {
+ $this->input = JFactory::getApplication()->input;
+
+ // Article frontpage Editor contact proxying:
+ if ($this->input->get('view') === 'contacts' && $this->input->get('layout') === 'modal')
+ {
+ JHtml::_('stylesheet', 'system/adminlist.css', array(), true);
+ $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
+ }
+
+ parent::__construct($config);
+ }
+
+ /**
* Method to display a view.
*
Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/370/infograf768/administrator/components/com_contact/views/contacts/tmpl/modal.php on line 21
Strange error:
As we use the same line in com_content modal.
https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_content/views/articles/tmpl/modal.php#L29
And $this->filterForm
it is defined for com_contact here: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/views/contacts/view.html.php#L78
Something must be missing in the code I posted above.
Both for xtd modules and xtd article, no need to load the modal as I did with
require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';
Let's hope someone can solve this.
Note: Concerning xtd menu, it is even another story as we have no com_menus in frontend...
Looks like I found a possible solution...
adding in the xtd (here for contacts)
/*
* Use the built-in element view to select the contact.
* Currently uses blank class.
*/
$app = JFactory::getApplication();
if ($app->isSite())
{
$link = 'administrator/index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
}
else
{
$link = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
}
I do get the modal OK and can select.
No need in this case to add require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';
Can someone test and look if this does not have a wrong effect? (security or else)
using the administrator index.php means you need to be login admin right? Did you test that when logout of admin?
I have a problem in 3.7.0
As super admin, when you login in admin OR site, you are logged in both...
you have shared sessions in global config set to yes right?
Sounds like #12068 in action
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
Ah, grrrr
shared sessions now off.
My trick does not work anymore when the user is not logged in admin. Forget it...
Welcome a completion of the patch proposed above...
@infograf768 why don't you replicate what have been done in XTD_modules? I mean the link @andrepereiradasilva posted in the first comment
that is what i tried to do for contacts. obviously not enough...
concerning xtd menu we do not have anu frontend com_menus...
you did the xtd modules, you may know better
@infograf768 your code is correct you just miss this change (add $config) in com_contact/contact.php:
$controller = JControllerLegacy::getInstance('Contact', $config);
Then it should work fine!
Labels |
Added:
?
|
ok, will try tomorrow for contacts.
any idea for xtd menu?
Adding , $config
helps. I also loaded backend language. I still get a Notice:
Notice: Undefined index: contacts in /Applications/MAMP/htdocs/370/infograf768/libraries/cms/component/router/view.php on line 86
And search tools is broken
For the xtd menus, I added in frontend an instance of com_menus with the same structure as com_modules frontend. Does not work yet.
For that one the modal displays The most recent request was denied because it contained an invalid security token. Please refresh the page and try again.
I am going to create a WIP PR to work in collaboration to solve these.
Closing as we have a PR by @infograf768
Status | Confirmed | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-10-06 09:35:13 |
Closed_By | ⇒ | zero-24 |
Labels |
Removed:
?
|
a WIP one... ;)
just as aditional info
for the contacts i think you need the frontend component proxying to admin when view = contacts
for the menus i think you may need the component itself on the frontend proxying to the backend
See com_modules as example: https://github.com/joomla/joomla-cms/tree/staging/components/com_modules