I use the Content by Label macro in many situations, but would like the page being viewed to not appear in the list generated. For example, I have 5 pages all related to Resource Management (my label). I want each of the 5 to display a link to the other 4 but not itself. How can I do that?
We have the Cloud version of Confluence, so Stephen's solution won't work for us.
If your version of Confluence has CQL filters ("Add a filter" option), you can add a filter for the "With Title" field.
Enter the title of the page with a minus in front of it (e.g., "-My Page"). That's the only way I could figure out how to do it, except that it's a pain to have to explicitly enter the page name. It would be nice if the macro could take an @self variable or something like it. (Maybe it can, but I haven't found anything on it.)
I don't think it supports a reference to itself, but one option would be to use the CQL Search macro and simply use a CQL query like
type=page AND space=spaceKey() AND id!=pageId() AND label=mylabel
and it would automatically generate a list of pages in the current space with that label excluding the current page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
I'll have to get approval to download and install the plugin, but this looks like the perfect solution for us.
Gabrielle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We can't install Stephen's plugin, but the CQL query macro will take his filter. Unfortunately, the CQL query macro (in Cloud version anyway) has a fixed report-style output format, with lines, a constant background color, etc., so it can't be used the way Content by Label is. It's not flexible enough. Why doesn't Atlassian listen to users, instead of always coming up with close, but not quite usable solutions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gabrielle,
I did write the CQL query macro for Cloud, so I don't see why I couldn't implement a different display style as a new feature. Stay tuned!
(At least I'm assuming you're talking about the CQL Search add-on; it's not very clear from your comment as there is no built in CQL Search macro that I am aware of that allows you to reference the current page/space)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, I'm talking about a macro called CQL Query. We also have a Search Results macro that uses slightly different syntax:
Neither of these macros allows any user control of output. It's very frustrating. It would be nice if the Content by Label macro, which does have output control, let us use a CQL query to refine the filter, instead of forcing us to use the crippled "user-friendly" interface. There's nothing friendly about being stopped from doing very simple things. I found out the "With Title" filter allows only the CONTAINS operator. In other words, there isn't any way to exclude the current page, even by entering each title, because the filter won't accept any form of NOT. You can just filter labels that way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm late to this, and it's not a perfect answer, but i can confirm that @[deleted]'s hack of adding -The+Name+Of+The+Page to the Title field works. Obviously not a great solution for large Spaces.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem I've found with the With Title -{my page title} filter is that there doesn't seem to be any way to tell it to exclude only pages with that exact title.
The page I'm trying to add the filter to is called Reports. However, there is another page which includes the word "Reports" in the title. If I add a With Title filter of -Reports that will exclude both pages. I've also tried -"Reports" (surrounding the page title in double quotes) and -'Reports' (surrounding the page title in single quotes), with no success.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's currently an open feature request for this feature:
https://jira.atlassian.com/browse/CONF-5245
But I did make a workaround until it can be implemented. I included a workaround in the ticket which I will duplicate here. If you include this in your Custom HTML (make sure you copy everything):
<script> $(function() { $('.content-by-label > li > div > a').filter(function() { return $(this).attr('href') === contextPath + '/pages/viewpage.action?pageId=' + AJS.params.pageId || $(this).attr('href') === contextPath + '/display/' + AJS.params.spaceKey + '/' + AJS.params.pageTitle.split(' ').join('+') }).parent().parent().hide().parent().next().filter('div').hide(); }); </script>
Then it will hide the current page from the results of the Content by Label macro. It's not perfect, but it should help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Stephen
Thanks for the quick response. I have a couple of questions:
Thanks again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works for the server version:
If you have Source Editor then you can add “label=yourLabel and content != currentContent()”
Another solution is to highlight the title of the current page in bold using space style sheets similar to the Page tree macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not a solution for Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandy,
You can filter Content by Label macro table with Table Filter macro to hide the page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.