How can I load a theme plugin only for a few, selected users? - cakephp-3.x

I have a CakePHP 3.4 application, which has been developed a couple of years ago and has a few thousands users.
I am currently working on a new version of this application, and my client wants it to be visible only by a few selected users before we release it for everyone else.
Unsure about what is the right way to do so I have chosen to develop a new theme plugin, which overrides a few controllers, layouts, assets, routes etc.
Everything is working correctly, but now I need to specify which users should see the newer version. To accomplish this I've added a theme field in my users table, and in my AppController's beforeRender method I have added this:
$theme = $this->request->session()->read("Auth.User.theme");
if ($theme !== null) {
$this->viewBuilder()->theme('Theme2');
}
To use the newer version I also need to load the new theme in my bootstrap.php:
Plugin::load('Theme2', ['bootstrap' => false, 'routes' => true, 'autoload' => true]);
So, if both the theme and the plugin are set, the user will see the newer version.
If neither the theme or the plugin are set, the user will see the old version.
My question is: how can I load the theme plugin only for selected users?

Related

Joomla 3.x - How to create article from frontend which is by default "featured" and "published"?

I am using Joomla 3.4 and want to provide group of users with possibility to create article (I need it to be by default PUBLISHED and FEATURED) but when they create new article it is NOT PUBLISHED and NOT FEATURED (users do not have possibility to change this setting in the fronted).
I am using standard joomla component - create article - when users are logged in they can add an article but than I have to login into admin modul and set "featured" and "published" when article is created.
I have tried to change
/joomla/administrator/components/com_content/models/forms/article.xml
AND
/joomla/components/com_content/models/forms/article.xml
I have set default=1 (featured=YES) but it does not work for me. Moreover in the article.xml article should be by default published but it is not.
add this:
if(!isset($data['state']))
$data['state']=1;
if(!isset($data['featured']))
$data['featured']=1;
to /joomla/administrator/components/com_content/models/article.php on save function.for example:
public function save($data)
{
if(!isset($data['state']))
$data['state']=1;
if(!isset($data['featured']))
$data['featured']=1;
Actually, setting Featured to default=1 in /joomla/components/com_content/models/forms/article.xml saved my day. All new articles are featured now by default.
This file is regularly overwritten by Joomla upgrades, so the correct override file has to be copied to:
/templates/system/forms/com_content/article.xml

Filter courses on Moodle 2.7

I am wondering if there is any plugin available for Moodle 2.7 which allows admin to add some attributes to courses and create a widget to filter the courses by thoses attributes.
For example, we would like to allow users to filter courses by their price, content, dates etc.
Thanks in advance
The block gnuwings provided will actually solve your issue when configured within Moodle correctly.
What you should do afterwards, is enable the 'My Moodle' page for every user. To find this setting, you should use the search function for the site admin.
My Moodle allows you to place blocks in the center of the screen, so you can edit the default My Moodle page to show this block. I would personally recommend turning the feature that allows students to edit their own My Moodle page off, as this will make it harder for you to manage this page in the future (without modifications to the database).
To edit the default 'My' page, in Moodle 2.7, go to site administration, appearance, default my page.
To enable this view by default, go to site administration -> appearance -> navigation, and update the value of 'Default home page for users'.

Add static javascript to every page of joomla

Im completely new to Joomla development. I need to develop Joomla plugin that adds static javascript to the footer of all the pages of a Joomla site. Also, the plugin would need to save 2 fields in database, and access these fields on per page basis. Also, Admin panel is needed.
Now, my questoion is, where do i start? Joomla plugin development is a big task, so if I can get some pointers as to where to start, it would be very supporting.
Im not asking for direct code, but just the right direction to start.
Thanx in advance....
Joomla has three types of extensions (what you refered to as plugin): components, modules and plugins, where each has a different purpose.
If you need to add javascript to all pages, the best place is your template. If you don't have access to template, just building an extension, then you have to create a content plugin.
If you need to create extension with admin panel which also works with database, you need to create a component. The best place to get started is tutorial Developing a MVC component for Joomla 2.5

Magento Multi Store themes calling same login.phtml file

I'm new to magento. Currently i'm developing two ecommerce sites using multi-store option in magento. Both the sites are 90% over, last night when i planned to customize the login page i was shocked. The reason is the changes made in first store login page also reflecting in second store also. The login page is curently calling from
frontend/default/default/template/persistent/customer/form/login.phtml
Is it possible to give any custom login page? PLz guide me magento experts......
Please update your post with your frontend/ folder structure down to each theme template folder. It might be that you don't have a copy of login.phtml in the second theme. Moreover you should follow templates best practices as:
Always create for a new shop different packaga. So not
frontend/default
but
frontend/yourcustompackage
Always have default theme left as much untouched, as possible. So in the
frontend/package/default
Should be some basic changes and rules of your package. It means for example in the putting reset.css for all of your themes. Or something like this.
As for me, each store view should have own theme. So, for example, storeview1
frontend/package/storeview1/
There you copy and change files specific for this theme. So, for example, in default you might have login.phtml. But you want storeview1 to have another login.phtml and in storeview2 it should be the same as in default. Therefore you copy the login.phtml from default to storeview1 and change it there. Don't forget to change package and theme in System->Configuration->Design. Package should be change for whole shop and theme should be specified for every store view or left untouched for default.
P.S. Magento theme fallbacks
P.P.S. Try this tutorial or google another one
P.P.P.S. I hope, you got the answer for your question.

Is there a way in Joomla to have public user profiles?

I installed Joomla 1.7 and I noticed that you can have user profiles with the user profile plugin. However, is there a way to publicly access a user's profile (without loging in)?
For instance, I noticed that you can go to:
/index.php?option=com_users&view=profile
However, that seems to pull up my own profile, If I am logged out it always redirects you to the login form. I have tried adding additional variables like "id=1", "user_id=1", or "userId=1".
Is there a way to do this? Or will I have to develop a component to pull in this information publicly?
Even though it not possible with clean Joomla website a lot of useful code come with it, which you could include to your component if you prefer to create one.
But... there is a great extension Community Builder with a great team behind it. Having used it in the past, I would highly recommend it as a solution for community based sites.
It changes the login form to a much better & bug-free form, enables more fields to be created for registration, and allows special pages for individual users, plus, community builder has extension-specific plugins.
EDIT: This answer needs an update as since it was added more extensions have been introduced like JomSocial or EasySocial. I cannot recomment CommunityBuilder any more
This post is tagged with Joomla 1.7 however I wanted to mention that if using Joomla 3.7.4 you now have the ability to show the User Profile plugin data from the core Contacts component. You can also add more custom fields to the Users component and they will also show from the Contacts component. You can set the display of the Users Profile info by going to the Admin panel -> Contacts -> Options. Turn on the option under; Contact -> User Profile -> set to "Show".

Resources