Can content ID be displayed in content editor?

Our business users have asked if the content ID can be displayed within the content editor - does anyone know of a way to do this? I have tried adding a field that has a default value of the sys_contentid, which has two problems:

  • I assume it adds another column to the content’s database table, which is unnecessary - I just want to display it, not store it redundantly
  • I got an error when creating a new content item, stating that the content ID cannot be null

Anyone have any clues for me?

One way to do this is to define the following binding for your template:
Variable Name: $contentid<br/>
Expression Editor: $sys.params.get(‘sys_contentid’).0

Then in your template call display the variable using something like:
content id: $contentid

Hope that helps…Rhonda

Thanks for the reply, Rhonda. But I’m not talking about a template or including the content ID in any output. I want to make it appear in the Content Editor window, with the other fields. Or maybe I’m misunderstanding you - is there some template associated with the editor itself?

Actually, it’s an XSL stylesheet. I think it’s called ActiveEdit.xsl, and it controls what you see in the content editor.

The XML does contain the content id, so modifying this stylesheet should show you the id.

The Installer overwrites this stylesheet when it runs, so you’ll have to redo the changes each time you upgrade. I don’t know of a way to do this that will survive an upgrade, but somebody may think of one.

Dave

Thanks, Dave. I found the stylesheet - I will give this a try.

Where is ActiveEdit.xsl located?

I got this to work. In case anyone wants to reproduce this, here are the details:

I modified two XSL stylesheets so that the content ID is displayed on both the content editor and the related content editor. Stylesheets are:
RhythmyxRoot/sys_resources/stylesheets/activeEdit.xsl
RhythmyxRoot/sys_resources/stylesheets/relatedcontentctrl.xsl

Here’s the code for activeEdit.xsl (in bold) - I added the table row with the label “Content ID:”

<xsl:comment>Start of Content Block</xsl:comment>
	<form method="post" action="{@submitHref}" name="EditForm" encType="multipart/form-data">								<!-- provide a hook for controls to get script to run when page is submitted -->
	<!-- each template should generate JS that returns a true/false value -->
	<xsl:attribute name="onSubmit">
	...
	<table width="100%" border="0" cellspacing="5" cellpadding="0" summary="controls for editing metadata">
	<tr>
		<td colspan="2"/>
	</tr>
	<tr>
		<td class="controlname"><label accesskey="" for="">Content ID:</label>
		</td>
		<td><div class="datadisplay"><xsl:value-of select="$syscontentid"/>
		</div>
		</td>
	</tr>
	<xsl:apply-templates select="ItemContent"/>

Here’s the code for relatedcontentctrl.xsl - I added a variable for the content ID ($parentcontentid), and then put that into the heading of the page in a table row:


...

...
<xsl:param name="relateddoc"/>
	<xsl:variable name="parentcontentid" select="@contentid"/>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<xsl:if test="not($mode='sys_edit')">
			<tr>
			...
			</tr>
			<tr>
				<td align="left" class="controlname">
				<b>Content ID: </b><xsl:value-of select="$parentcontentid" />
				</td>
			</tr>
			<xsl:apply-templates select="slot" mode="mode1">
			...