Editing Files from the MODX Manager’s Top Menu

Suppose you have some files on your MODX site that you edit often. I’m always hacking away at the main .CSS file, .htaccess, and sometimes a few JavaScript files. It’s a pain to keep going to the Files tab, waiting for the File tree to render, finding your file, and clicking on it. Wouldn’t it be nice to be able to get there directly from the Manager’s Top Menu? It’s actually very easy to set this up, and you don’t have to write any code.

Creating the “My Files” Top Menu Item

  1. Go to System | Actions on the Manager’s Top menu.
  2. On the right side, Right-click on the Top Menu folder and select “Create Menu.”
  3. Put “My Files” (without the quotes) in the key field. Use a different name if you like.
  4. Add a description (optional).
  5. Select “No Action” in the Action dropdown.
  6. Click on the “Save” button.

The following steps will be repeated for each file you want to add:

  1. Go to the Files tab and click on a file you want to add to your menu. You should see the file’s contents in the Create/Edit File panel. Using the mouse, highlight and copy (Ctrl-C) the parameters from the URL in your browser’s address bar to the clipboard. Copy just the part from the first & to the end.
  2. Go back to System | Actions.
  3. Right-click on the “My Files” menu item you just created and select “Place Action Here.”
  4. In the Action dropdown, select “core – system/file/edit”. It should be on page 4 of the list.
  5. Paste the parameters you copied before (Ctrl-V) into the “Parameters” field.
  6. Click on the “Save” button.

Repeat the steps above for each file you want on your menu. That’s all there is to it.

You can click-and-drag the “MyFiles” item to a different location in the Top Menu and you can reorganize the files under it by dragging them up or down in the tree.

You’ll have to reload the Manager page before your Menu items will show up.

Making Them All Top Menu Items

If you have a small number of files to edit and you don’t want to bother with a drop-down list, you can make each one a Top Menu item. Just combine the two sets of steps above. For each file:

  1. In Manager | Actions, Right-click on the Top Menu folder.
  2. Select “Create Menu.”
  3. Enter a name and description.
  4. Select “core – system/file/edit” for the Action.
  5. Paste the parameters for your file in the “Parameters” field.
  6. Click on the “Save” button.

You can drag the menu items up or down to reorganize the Top Menu.

Permissions

There may be some users on your site who shouldn’t be able to edit the files (or see the menu items). Protecting the menu items is simple. You may have noticed the “Permissions” field when you created your menus. That field can contain a comma-separated list of permissions (or a single permission) a user must have in order to see the menu item. Adding the sources permission will restrict access to users who have the right to manage Media Sources. If you want to be more restrictive, you can use access_permissions. Only very high-level users should have that permission (it allows users to change their own security status — and yours!). You can use any permissions here that are listed in the Administrator Policy. You can also create a custom permission here (call it anything you like) and add it to the Administrator Policy template.

Important! If you mess with permissions, keep two things in mind. First, be careful typing them. If you misspell a permission, not only will it not work, you won’t have that permission and you won’t see the menu item in the menu *or in the tree*, so you won’t be able to fix it except by going into the database in PhpMyAdmin. Second, make sure that you have the permission you enter *before* adding it or the menu item will disappear from the tree.

For more information on how to use MODX to create a web site, see my web site Bob’s Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for quality MODX Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under MODX | RSS 2.0

Author Spotlight

Bob Ray

Bob Ray

I am the author of MODX: The Official Guide and over 30 MODX add-on components. I host Bob's Guides, a source of valuable information for MODX users, and I've been very active in the MODX Forums with over 18,000 posts.

Leave a Reply

Your email address will not be published. Required fields are marked *


4 + = 12

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>