I'm trying to add a unique ID to page titles in confluence.
I managed to add a user macro which uses jQuery to add the page ID & a string prefix to the title;
## #param _prefix:title=Prefix|type=string|required=true|desc=Prefix for the page ID
<script type="text/javascript">
jQuery("document").ready(function() {
if ("${param_prefix}" != "${_prefix}")
jQuery('#title-text a').prepend('${param_prefix}', '$content.getIdAsString()', ' ');
});
</script>
But I want this to actually edit the title, not just get added at runtime. It needs to be consistent throughout, allowing that ID to be a search term & appear in all menus etc.
I can't find anything which suggests this is even possible but it must be, surely!?
$content.setTitle("newtitle") should work. BUT! you will have to make sure that this only happens once, otherwise your title will get repeatedly prepended with your text every time this macro is rendered. I guess you might check if the title starts with your prefix already. And then you might want to add handling of changing the prefix.
See http://confluence.atlassian.com/display/CONF35/Guide+to+User+Macro+Templates#GuidetoUserMacroTemplates-OtherObjectsAvailabletoyourMacro for more details.
That being said, this seems like a pretty kludgey way of solving whatever problem you have. I would suggest reconsidering if this is really what you want to do.
You can use the actual Confluence page ID or the page tiny link rather than generating an ID of your own. Both of these are static.
On any Confluence page, type "k" to see a hyperlink. You might be surprised to see it also contains a tiny link. Atlassian confirms that the tiny link stays the same, even if you move and rename the page (https://jira.atlassian.com/browse/CONF-27049). This is a consistent way to reference the same page with a fixed URL. Another way is to use the Confluence built in PageID.
Confluence Knowledge Base: How to get Confluence page ID
https://confluence.atlassian.com/confkb/how-to-get-confluence-page-id-648380445.html
Ensure that the current user has permissions to View and Edit the
page Navigate to a specific page
Go to Edit Mode by clicking Edit button or press 'e' key
The URL in the address bar will change once you enter Edit Mode
Page ID will be displayed as the parameter in the URL e.g.: When entering Edit Mode, the URL will change to http://my.domain.com/pages/editpage.action?pageId=1540132
In the example above, 1540132 is the Page ID.
To get the page ID with a macro:
ContentEntityObject contentEntityObject = conversionContext.getEntity();
System.out.println("pageId : " + contentEntityObject.getId());
To change a title: content.setTitle("newtitle").
Remember, check if title contains the page id before setting title = title + page ID.
Related
I am compiling a lead generation landing page and, in the form I have inserted a hidden field which collect whatever is written in the url bar after
"?rel=".
This is done in order to track where the leads come from (Facebook ads, direct linking etc).
To be more clear if this is the url: www.mywebsite.com/form.html?rel=fbads
the hidden field will be fill with "fbads" and this is working.
In the landing page I have a link to another page with more details and in this webpage I have the same form.
My idea is to run campaings on the first page with the rel link, but then if the user clicks on the link and go to the detailed page (and then compile the form from there), I am losing the rel field.
How can I pass the rel field to the url of the second page?
Thanks
You may refer the this stackoverflow page. Once the HTTP GET request comes, traverse in HTTP headers in your controller and look for Referer field but it is not always set and the client can change the header value. May be using google analytics is the better option.
If you just want to know that whether if they came to your form page from your landing page or not, you may add fix HTTP URL parameter prior to HTTP redirect.
If you save your rel in a variable, you can add it on your link to detailed page, for example in case of =fbads just once variable is set up, add it: <a href="http://myDetailedPage.com/detailed/?=<?php $rel;?>"</a>
there was a similar question to this one asked a while back - but for some reason the comment that contained specific instructions for the workaround was deleted.
I am attempting to create a landing page on a tumblr page using the redirect code below.
<script type="text/javascript">
if(location.href == 'http://labellablog.com/') location.replace('http://labellablog.com/welcome');;
</script>
The issue that I'm experiencing is the same as the person who posted the question in the first place - by putting the redirect code in the index page, it creates a loop. i.e. In trying to click the link on the 'welcome page' in order to get to the home page containing blog posts, navigation etc., it simply re-directs to the 'welcome' page.
The solution that is mentioned (not in great detail) on another question states that you must set the cookies to expire in a certain amount of time. Unfortunately I'm a huge amateur when it comes to coding and am not entirely sure how to achieve this.
Thanks in advance for any advice.
Method 1
Based on your question this is how I would resolve it (this is not using the cookie method at all, but I will come to that).
Make sure jquery is installed in your theme, alot of themes already have it, if not you can add it to the head of the document like so:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
Lets look for the index page:
var primaryDir = document.location.pathname.split("/")[1]; // get the first directory
if (!primaryDir){ // if the primary directory is empty (index page) lets redirect to another page
window.location('/welcome');
}
You can use /welcome and that will work if you change the name/url of your site/tumblr.
So this method means this will always run (unless you disable javascript) for every client that connects to your site. This means effectively that the index page is never visible.
Now if you wanted a cookie method, this would mean that you would create the redirect on the first visit, then set the cookie and then after that the index page would be visible.
If that is what you want, let me know, but that involves quite a bit more code, slightly more complex solution.
EDIT
Another way to achieve this is to create a hidden div in the main template that only shows on the index page and is hidden on all other pages, this means you don't have to rely on a slightly slower redirect.
I only posted an answer to that issue the other day: How can I make a Tumblr background image only for one page?
Method 2
OK here is a method adopting cookies.
First I recommend downloading this jquery cookie plugin
You will then need to link to that as a resource in your theme, so you need somewhere to host that file. I use dropbox, but tumblr also has a repository for linking to files (well it used to seems to have disappeared).
Now create an element that will sit over the main page:
Enter
You can style this to fill the whole page if required (modify to your needs):
#entry {
position:fixed;
top:0;
right:0;
bottom:0;
left:0;
background:#CCC;
color:#FFF;
// yadda yadda
}
Now we need some click event to create the cookie when we click on this huge anchor:
$(document).ready(function(){
var entry = $('#entry'); // lets cache the selector in a variable
entry.on('click',function(){
$.cookie('deadlyrhythm', '1', { path: '/', expires: 1}); // set a cookie with the name deadlyrhythm to the value of 1 on the entire site for 1 day.
$(this).hide();
return false;
});
});
Now we need a method to check if the cookie exists, so inside the same document ready function:
if ($.cookie('deadlyrhythm') != '1'){
entry.hide();
}
This should mean that for 24 hours the cookie is set and the entry will not display if the same user revists the site, but it will after one day, of course you can set that value to anything you like.
As I mentioned this is slightly more complex to implement, but in the console of the browser you can check to see if a cookie exists and delete it manually (I use chrome for this) this is really useful for testing.
I am using Confluence via Emacs confluence-mode, and I would like to give my pages a meaningful name, but then also give them a short name that would make it faster to type when editing. Can I create a page that is just a link to another page with a different name?
For example, create a page called My meaningful name for this page and then create a link to that page called p1 that is simply a pointer to the other page. When opening p1, it would actually be opening the other page.
Essentially, I want to be able to open the page:
http://my-confluence.mydomain.com/display/MySpace/p1
And end up with:
http://my-confluence.mydomain.com/display/MySpace/My+meaningful+name+for+this+page
Any ideas?
Sounds like you need a redirect. On your p1 page, throw this inside an html macro:
<script type="text/javascript">
window.location.href("http://My meaningful name for this page.com");
</script>
That will automatically redirect to the correct page. Only downside is it might visibly show the p1 page for a fraction of a second. If it does, and that is unacceptable, I would refer you to this answer on Atlassian's forums:
https://answers.atlassian.com/questions/124121/how-to-properly-redirect-pages-in-confluence
It lists 2 plug-ins, one of which I use, which do it very seamlessly. They're not free though.
Can you describe your use-case a bit more? You can achieve this by using anchors (https://confluence.atlassian.com/display/DOC/Working+with+Anchors) if you're linking to the same page. If you need to link to a new page, this might help:
https://confluence.atlassian.com/display/DOC/Configuring+Shortcut+Links
Facebook provides us with an option to choose a custom landing tab for the new visitors (i.e. non-fans). Can we have a custom Landing tab for fans so that every time i open the page, i m directed to that custom page rather than the Wall..
Have you checked Facebook Help Center?
How can I select a tab as default for people who already Like my Page?
This functionality does not exist.
What you are trying to do is straightforwrd.
Create a "landing page" tab app and add it to your page. Here is a tutorial on how to do it: http://how-to-create-facebook-app.koliber.com
Make this tab the default for your app. On your page, in the upper-right corner click "Edit Page" and change the "Default Landing Tab" to the one you would like displayed by default.
Now everyone will be shown the default tab when they log in. How to distinguish between those visitors who "liked" your page and those that didn't? Easy. Make two versions of the page and display one to those who liked and one to those who didn't like. How to find out whether the current visitor liked your page or not follows:
When your Page Tab URL is called in the iframe, it is passed a signed_request POST parameter. This parameter contains the info you need. However, it is encoded and structured so it needs some processing to get the info
Split the signed_request on the '.' character. The first part is the signature. The second part is the encoded_data
Decode the encoded_data into a JSON string using the URLBase64Decode function equivalent in your server-side programming language
The JSON object contains a node called "page". This contains a node called "liked".
If "liked" is true, the user liked the page and you display the "liked" version of your app. If false, show the "Please like me" version of the site.
This way, when visitors visit your page, they see your custom app in a tab. The actual content is determined server-side on your server based on the page.liked property inside of the JSON object passed to you in signed_request
The simple answer as far as I have been able to find out is "No". There is no setting which aligns with this requirement.
The wall is the default tab for people who like the page.
http://apps.facebook.com/static_html_plus/ this application gives you those options... enjoy!
I created FB application that use iframes, and it's working okay, as it should, BUT I need to check from what page is calling it.
I want different pages to pass different variables to that iframe location.
I already know how to set up it to three levels ( original page, application page, and on tab page, with different display content ), but I need to check from what page it's called.
I am thinking that it can be done in 2 ways:
1 way: Find way to pass specific variable based on page that is using this application as tab, and then redirect it to right location
2 way: Find way to create new application outside facebook ( maybe API or something ) and then enter all those values including: App name, app link that have this variable included, app tab link, using iframe and not FBML...
I will love to use 2. way...
I'm not asking you to show me code, I know that I need to do my job, I'm not asking you to do it for me, I'm just asking for help, for directions from someone who already create something like this, to point me to right direction where can I find way...
Also, please don't tell me to read bunch of stuffs, like FB Documentation or whole book that have all other "not-used-here" stuffs, I need specific part where there is a word about this...
If someone know anything about this, write it here...
Thank you!
The "page" parameter is passed along within the "new" signed_request parameter on (iframe) tabs. You get what you need for "free" ;)
page: A JSON object containing the page
id string, the liked boolean if the
user has liked the page, the admin
boolean if the user is an admin. Only
available if your app is an iframe
loaded in a Page tab.
http://developers.facebook.com/docs/authentication/signed_request/