Jump to content

Custom link in admin menu


Zeka
 Share

Recommended Posts

Hi.

I need to output some custom external and internal links in admin sidebar navigation menu.

Is there some predefined way to do that or i have to create process module?

Thanks

Link to comment
Share on other sites

For static links you could use AdminCustomFiles and append the links with jQuery.

Beyond that you could duplicate and rename the admin theme module and then code in whatever links you need, as I don't think the menu render function is hookable (for the default theme at least).

Or a process module, as you say.

Also, if by internal links you mean links to edit a particular PW page remember that you can set up page edit bookmarks.

  • Like 1
Link to comment
Share on other sites

Another way is to insert it via JavaScript.

Note, this example is tested for the default admin theme, not Reno.

First place the following in your admin.php file above the require controller line, inside your templates dir:

$config->scripts->append($config->urls->templates."admin.js");

Then place the following in a file called admin.js in your templates dir:

$(document).ready(function(){
  $('#topnav').append('<li><a href="https://example.com/" target="_blank">Example</a></li>');
});

I'm sure the jQuery could be more elegant, but the point is it can be done via JS as well, which I ended up doing for a recent project for reasons I can't remember.  In my specific example, I linked it to a Google Doc which contained help documentation for a site.

  • Like 2
Link to comment
Share on other sites

  • 2 years later...
On 6/3/2016 at 7:25 PM, Jonathan Lahijani said:

Another way is to insert it via JavaScript.

In case anyone should need it, this still works with the latest UiKit Theme, just replace the jQuery selector with:

$(document).ready(function(){ 
  $('#pw-masthead .pw-primary-nav').append('<li><a href="https://example.com/" target="_blank">Example</a></li>'); 
});

Or @Jonathan Lahijani's recipe for a less quick & dirty approach:

https://processwire-recipes.com/recipes/create-custom-admin-settings-page-link-in-admin-menu/

  • Like 1
Link to comment
Share on other sites

44 minutes ago, andi said:

In case anyone should need it, this still works with the latest UiKit Theme, just replace the jQuery selector with:


$(document).ready(function(){ 
  $('#pw-masthead .pw-primary-nav').append('<li><a href="https://example.com/" target="_blank">Example</a></li>'); 
});

Or @Jonathan Lahijani's recipe for a less quick & dirty approach:

https://processwire-recipes.com/recipes/create-custom-admin-settings-page-link-in-admin-menu/

Just a note, better to update the recipe code to:

if($page->template=="admin" && $page->parent->id==2 && $page->name=="settings") $input->get->id = $pages->get("/settings/")->id;

 

  • Like 1
Link to comment
Share on other sites

  • 8 months later...
On 3/4/2019 at 7:41 PM, andi said:

This seems like one of the nicest, cleanest methods to do this, but for me it doesn't work. I end up on this page instead

image.png.ec655219186f67c846278467f8ca040c.png

The Url is /manage/settings but when I click it I'm redirected to /manage/settings/bookmarks

What am I doing wrong?

Link to comment
Share on other sites

@cst989 The issue could be that you incorrectly set ID of a page and then you get redirect to bookmarks page. Redirect is handled here https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L77

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...