CakePHP: best way to remove a field from the admin scaffold - cakephp

When I admin-scaffold the Users model, everything works great. However, it also has the "password" field. Which is a hash of the actual password.
When you save a user in the admin console, it saves the hashed password, which screws everything up.
What's the simplest way to exclude a field from the admin-scaffold with minimal interference to the awesome auto-magic of the admin-scaffold?
Thanks

You will want to make your own bake theme, so you can then edit the template to remove the file.
It really is as simple as this, http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html#modify-default-html-produced-by-baked-templates
Just copy the files from inside lib/Cake/Console/Templates/default/views into your project under app/Console/Templates/[themename]/views and then you can edit the view templates.
The same applies to all the other files too, such as controllers and models. Then when you bake your project you'll be asked which theme you want to use and you can select your own.
Here is an example from one of my projects.
The only real thing to note is that your theme names must be unique!

Related

How do I modify Drupal's Admin Screens?

I'm looking to edit Drupal's admin pages.
Some of the things I'm trying to achieve:
Remove is the the filter setting on the Content page/node/view. In other words, if I go to to the Content page and I filter by a certain type of node, then I leave that page, then come back, the filter setting is saved, I'd like it to reset each time I visit the Content page.
I would like to modify some of links associated with these pages, as an example on that Same Content page, the titles of the pages are linked to their 'front-end' views, I'd rather have them link to their 'edit' screens.
While I have been successful in modifying the front-end theme of Drupal, by editing the actual php files. I can't find the the same php files for the Admin theme. In our case we are using Seven (7.21). I've read something about views, and thought maybe the entire Admin theme is built as views, aka there no php files involved like the front-end theme has, but under the Views section I did not find any either. I'm still pretty new at this and coming from the Wordpress world, this is a Drupal is a lot different.
The logic for that section of the admin area is at (from the public root):
/modules/node
Specifically "node.admin.inc"
That being said, I don't recommend editing core scripts, as they will be overwritten when you update the core.
You could explore making your own module to supplement that page, or your own view or explore some pre-made modules, such as "Admin Views"
Find de view displayed and go to its configuration :
1 - Edit configuration view like suggested here : https://drupal.stackexchange.com/questions/44440/how-to-remember-exposed-filter-choices
2 - Rewrite output views to rewrite link : field https://www.drupal.org/node/1578524
Another option is to create and use your own dashboard/views to achive like you want http://definitivedrupal.org/suggestions/creating-custom-administrator-view-content
also you can see contrib module : https://www.drupal.org/project/admin_views
You don't have to use that default content overview page at all. Make your own instead:
Make a page view (you have to install views module if you already did not: https://www.drupal.org/project/views) and use table layout. Make sure that page paths starts with "admin" so it will use admin theme. Also pay attention about permissions, so only specific set of users (admins) can use it.
For that view you can freely select what columns you what to show. You can also allow ordering by any column and action if you click on some field.
Use exposed filters to add filtering form, again add any filters you need. You can even set the form to use AJAX, to do auto-submit when some filter field is changed, include reset button and more. Also for every exposed filed you can select (at fields settings) should it remember it's value or not.
At end, edit admin menu and add your new page to it so it will look and act as default one but will offer much more functionality. You can even totally remove default one from the admin menu.
Views module is very powerful, not only for front-end but also for back-end content handling.

How to set a modules settings in Drupal 7 programmatically? (admin settings) ( not with hook_form_alter() )

I have modules coming with empty admin setup page.
I'd like to set up this module programmatically.
This page is basically a form. I know I can change this form with hook_form_alter() however for this to work I need to go to this page and press save. This is NOT what i'd like to achieve, I'd like to do it programmatically.
What are my options?
(These modules are not my custom codes. I have them from drupal.org so I have them as they are, I need to write my code that makes this happen. (a module ideally))
Look at the module's code. Most likely, it is storing its configuration in variables, so you should just be able to set the variable from your own code and dodge the form altogether.
The Closest answer can be found here: here
Which says:
look at drupal_form_submit() to programmatically submit a form -- its like visiting the form in a webpage and submitting it without ever opening a browser window. Whatever logic that form does upon submission -- will still happen
Another solution can be that it is storing data as a variable, or just in the database somewhere.

plugins for cakephp view

I am very new to cakephp and I see a folder plugin in my application
when I go to the site I see the address as
mysite.com/user/mergerdata
mergerdata is a plugin
When I click on add I see this
mysite.com/account/mergerdata/add
so when I go to app/plugins/mergerdata/controllers/merger_controller
I dont see an add action, But I do see the user_add action there
Am I looking at the wrong place. Where is User comning from. Where is Add coming from ???
"user" is a prefix, similar to an admin prefix. You can read more about it on http://book.cakephp.org/view/950/Prefix-Routing
Basically, this feature allows you to have different methods for different levels of users, and the prefix ("user") is added to the front of the method name ("add").

Joomla - clone user on register

I'm looking for a way to add Joomla user to custom table (PrestaShop - same database) - duplicate user on registration.
So user will be able to login to Joomla and second script (PrestaShop) using same login information.
Any ideas where I should start looking in Joomla files?
I know, that custom user plugin will be a better way to achive user duplication, but now I'm looking for temporary hard-coded fix until I'll be able to write a plugin.
(Joomla 1.6)
The other solutions won't let you save the passwords. If you are looking for saving the password as well then you will need to look into
components\com_user\controller.php
function register_save() {}
Note: I have given with reference to joomla 1.5. It might slightly vary if you are using joomla 1.6

How to auto generate a webpage after user submits form

I am looking for some initial direction on this one because I cannot seem to find my way with it. Let me explain...
I am developing a website wherein a logged in site member (Joomla 1.6) can fill out a simple form and attach a pdf to be uploaded upon submission. The user then clicks the submit button and the page will refresh to a new and unique web page.
User Submits data on http://www.examplesite.com and then after submission a new web page is generated that is called http://www.examplesite.com/userSubmittedValue
This newly generated web page would come from a template that is specified by the administrator and, most important, it will display all of the information that the user submitted. Also, there would be a link to download the pdf they uploaded. The user could then view a list of all the pages they have created in this manner via their profile.
I have seen this all over, but I am at a loss for how to generate this. Any help is much appreciated.
This is not something you will be able to easily do or get a detailed answer for here. If you just wanted to do the submission form with a thank you page that shows the data submitted you could use any number of form wizard type extensions - http://extensions.joomla.org/extensions/contacts-and-feedback/forms
If you just needed a way for users to upload PDfs and have access to them you could use one of the file management extensions that offer front end upload features - http://extensions.joomla.org/extensions/directory-a-documentation/downloads
If the additional data that is being submitted is simply data related to the file - title, description, etc then one of the file download components should work fine for you. The choices are limited in 1.6 at this time though so you might have to go with 1.5 to get the extension that works best for your needs.
So this probably isn't the best way to do it if your using Joomla but it just might help.
I would use PHP and inside of you're directory have a file like "template.html". Then I would create some php to handle the task of....
Opening "template.html"
Finding and replacing the values that the user passed you
Save the "template.html" under a new name (userSubmittedValue.html)
Again, I never really use Joomla. If you were to try this I'd suggest checking out php's file system functions (http://us2.php.net/manual/en/ref.filesystem.php).
Hope this helps a bit.

Resources