One one of our sites, we have ChannelFiles add-on installed and in the control panel (when editing an entry) it outputs a useful set of variables (see attached). But this is only part of add-on and if it's not installed, those variables aren't outputted. Is there anyway I can output these variables without ChannelFiles?

Background: There are certain fields that I only want to ever appear when editing a specific entry so I include a bit of jquery in the field instruction to hide/show field by checking against the variables outputted by ChannelFiles add-on in the script tag.



UPDATE (to clarify): I need this when editing the entry in the control panel of EE (see Background section on why) and not in the front end. As far as I know, I don't have access to the templates for the control panel (or do I?).

2 Answers 2


You can output entry ids from within the channel:entries tag pair like this:

{exp:channel:entries channel="my_channel"}
  entry_id: {entry_id}<br>

The Channel Entries documenation at EllisLab provide all the variable options available to you.


You can add this script to any of the field's Field Instructions section.

  $(document).ready(function() {
    entryId = (document.URL).split('entry_id=')[1].replace(/\D/g,'');
    $('.heading h2').append(' #' + entryId); // adds to heading at top of form
    alert("entry id = " + entryId);

Second Update

The previous script wasn't removing numerical characters from the url that occurred after the entry_id. The problem is that EE encodes the & as &amp;. So here's this:

  $(document).ready(function() {
    firstPart = (document.URL).split('entry_id=')[0];
    entryId = (document.URL).split('entry_id=')[1].split(firstPart[firstPart.length -1])[0];
    $('.heading h2').append(' #' + entryId);
  • Second update works beautifully (although I don't really understand what's going on on this line: entryId = (document.URL).split('entry_id=')[1].split(firstPart[firstPart.length -1])[0]; ). Thanks
    – Abs
    May 22, 2013 at 11:09

I'd output the entry_id to the page as a hidden value, much as Stephen suggested, and then look to grab that with JavaScript. If you're viewing a specific entry_id for the page you're viewing then you made need to pass that in as a parameter:

{exp:channel:entries channel="my_channel" entry_id="{entry_id}"}
    <p class="hidden">entry_id: {entry_id}</p>

If you're just looking to use JS to show and hide specific fields depending on an entry ID however then you could do that purely on the server-side:

{if entry_id="10"} ... {/if}

This would have the benefit of being usable by those without JS enabled too.

  • Please see my update.
    – Abs
    May 21, 2013 at 10:43
  • In the case of the CP the easiest way is a little 'hack' to inject custom JS into the field instructions box. Just place your custom JS between script tags in there and it will run/output on the CP publish page.
    – Ian Young
    May 21, 2013 at 10:51
  • That's what I am doing with the website that's running ChannelFiles add-on. Because the add-on outputs those variables in the entry edit pages (imagebin.org/258416) in the control panel, I can do a quick if-statement in JS to hide/show the field depending on the entry_id. My question is, on websites that aren't running ChannelFiles add-on, how can I have access to those same variables? I hope am making sense.
    – Abs
    May 21, 2013 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.