ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Linking to a page in the control panel from a template

November 15, 2010 7:17am

Subscribe [2]
  • #1 / Nov 15, 2010 7:17am

    FirthCreative

    89 posts

    This might seem a bit obscure but I am looking to create links to the entry form within the control panel from an area of site that only site admins have access to. Looking within the control panel I can see how the links are structured, what I am struggling with is accessing the session_id to include within the links.

    Is there a way of grabbing session info inside a template for use with such a requirement?

  • #2 / Nov 16, 2010 7:54am

    Boyink!

    5011 posts

    Is using sessions for the CP a requirement?  I create “edit this” and “add new” links on all my sites - but just switch the CP to cookies.

    I’d also experiment with just dropping the session id from the link. Seems like I’ve done that before as well.

  • #3 / Nov 16, 2010 8:02am

    FirthCreative

    89 posts

    I don’t suppose sessions are a requirement, to be honest I never thought about switching them off! I will need them in the frontend though so will need to check that they will still be available where required…

    I did try removing the session id from the url but it didn’t work, it left the link as follows (in case I am making another blinding mistake!!)...

    <a href="http://{cp_url}?C=content_publish&M=entry_form&channel_id=5&entry_id=2">Edit This Entry</a>

    I seem to end up at the site_index when I click the link, although the URL shown in the address bar is as dictated by the anchor href?? Is it possible my htaccess is stepping in and messing things up a bit?

  • #4 / Nov 16, 2010 8:08am

    Boyink!

    5011 posts

    Looks close to my eye.  Here’s my template code (I just pass in channel and entry id’s as embed variables):

    {if logged_in == "1"}<a href="http://{cp_url}?S=0&D=cp&C=content_publish&M=entry_form&channel_id={embed:my_channel}&entry_id={embed:my_entry}" title="Edit Entry" target="_blank" rel="noopener">Edit This</a>{/if}
  • #5 / Nov 16, 2010 8:20am

    FirthCreative

    89 posts

    hmmm, not sure what’s wrong here?

    The only reason the ids are hard coded is that the rest of the template isn’t complete - I was just testing with known good values.

    That said I added in the S=0&D=cp at the beginning of the GET data and switched the control panel to cookies only - but still the same result?

    my htaccess is…

    RewriteEngine on
    RewriteCond $1 !^(assets|downloads|images|system|themes|favicon\.ico|robots\.txt|index\.php) [NC]
    RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{HTTP_HOST} ^mydomain.com/$ [OR]

    I for the life of me can’t see why it wouldn’t be working!

  • #6 / Nov 16, 2010 8:23am

    Boyink!

    5011 posts

    Can you remove htaccess temporarily? 

    FWIW I use that template in my EE classes and it’s worked reliably for students on both Macs and PC’s - but we don’t do any htaccess stuff.

  • #7 / Nov 16, 2010 9:04am

    FirthCreative

    89 posts

    I got it working by replacing the {cp_url} with the full url to the control panel, turns out it pushes in the ‘system’ part instead of the renamed directory! Couldn’t see it for looking at it!

    Thanks for your help

  • #8 / Nov 16, 2010 9:07am

    Boyink!

    5011 posts

    Ah - didn’t know that.

    I’d actually log a FR for changing that. It should respect a renamed system folder.

  • #9 / Nov 16, 2010 9:29am

    FirthCreative

    89 posts

    Would it be a FR or a Bug?

  • #10 / Nov 16, 2010 12:02pm

    Boyink!

    5011 posts

    That’s a line I like to let the EL guys draw..😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases