Card macro - Is there a way to link to a specific card? (like using anchor or something like that)
Asked by Fabian Lopez:

I have information organized by cards (deck-card macro) and I would like to add links to specific cards from other pages. Is that possible or should I use a different macro to organize the information.


Answers:
author: David at David Simpson Apps
body: With a bit of JavaScript on the source and target pages this could be achieved. Likely the most user friendly way to do this would be to wrap the links in a user macro that appends ?targetTabText=Click+Me to the target page URL. The target page would have a user macro containing some JavaScript that grabs the request parameter, searches for tabs containing that text -- "Click Me" -- and performs a click event on the tab thus revealing the content. I'd do it now if I wasn't using a mobile device ;-)

comments: author: Fabian Lopez
body: Thanks David!


author: SandeepVK
body: Hello

Is there any solution? I am a beginner so it would be very helpful if you can share the code


author: Laurent Corbi?re
body: Hi,

Here is a workaround:

* give an ID to your card. Lets say "anchor2" for the 2nd card. Your deck has already an ID you choosed. Lets say it's "mydeck"
* to make the link, use the HTML macro
* then, inside the HTML macro, make your link like this:  

  ```
  &lt;a href="PAGE URL#mydeck-anchor2"&gt;LINK NAME&lt;/a&gt;
  ```

Have a nice day

comments: author: Colin Kemp
body: I've tried this from a direct URL entry e.g.

https://\<page-url\>#mydeck-anchor2

with no luck

Details:

### Confluence 6.7.1 {#toc-hId-1595925251}

Chrome: Version 64.0.3282.186 (Official Build) (64-bit)

Windows 10

Is there actual official reference documentation from Atlassian somewhere on how to use the card id as an anchor in a deck of cards?


author: Laurent Corbi?re
body: Hi Colin,

I just tested it on Confluence 6.5.2 / Chrome 65.0.3325.162 / Windows 7, and it's functionnal for me.

There is no official doc. I found it by inspecting a classical anchor url.

Regards


author: Colin Kemp
body: Well - thanks for the quick response.

I tripled checked the mydeck ID and the card ID and formed the URL with

\<mydeckID\>-\<cardID\> as you suggest but when I bring the page up the first card is the one on display.

I'll keep having a look


author: Laurent Corbi?re
body: Just to make sure, the url to "yourspacekey" with "more than one word" page title should be:

```
...confluence/display/yourspacekey/more+than+one+word#mydeckID-cardID
```

Make sure that your page doesn't have any special characters because it'll turn your url name in page id.


author: Colin Kemp
body: Thanks again. Yup I dumbed down the tags since they had an _ and a . but still no luck.

Essentially looks like:

.../confluence.company.com/display/space1/Release+Notices+Bulletin+List#releaseNotices-r13

where

Deck of Cards id = releaseNotices

Card Id - r13

There must be something else messing up on the page, as it defaults to the r1 (first) card tab each time for me.


author: Laurent Corbi?re
body: Maybe you should try on test page with simple page title, simple anchors name and 2-3 tabs without content.

Sorry for this newb error check, but make sure that you don't mix up card label and card id ;)


author: Colin Kemp
body: Laurent,

I created a test page as you suggested. Everything works perfectly with the new page.

Even to the point where when you select the new tab, the URL in chrome is automatically updating when the you traverse between the cards:

.../confluence.company.com/display/myspace/Deck+of+Card+indexing+test#deck1-card1id

click on card 2 and the broswer URL automagically becomes:

..../confluence.company.com/display/myspace/Deck+of+Card+indexing+test#deck1-card2id

So I'm speculating it might be a "legacy" issue with pages with Deck of Cards created before a certain point because I can't get it to work on that page. I might try creating a new page and migrating content over from the one that is not working to see if I can get it to work ... thanks for all the interaction on this one Laurent.


author: Laurent Corbi?re
body: You're welcome :)


author: Truc Nguyen
body: Hi Laurent,

Questions for you:

* I am using an older version of Confluence 5.10.8 -- will your work-around work?
* When you said HTML Macro --\> is it the Bob Swift HTML Macro?
* And to make the link --\> where would you add this script to in the HTML Macro?
*

  ```
  &lt;a href="PAGE URL#mydeck-anchor2"&gt;LINK NAME&lt;/a&gt;
  ```

I have tried it out making sure that the page doesn't have any special characters like your example

confluence/display/yourspacekey/more+than+one+word*#mydeckID-cardID
<br />*But I still cannot create the link so that I can use to access to a specific card in the Card macro.


author: Truc Nguyen
body: Thanks, I found my answers.


author: David Peterson
body: If it's not working, feel free to raise a bug report at <http://greenhouse.customware.net/jira/browse/POSI> with the details of browser, Conf version, etc.

comments: author: Fabian Lopez
body: <https://greenhouse.customware.net/jira/browse/POSI-167>

done. Thanks!

Good job on this one. Thanks!


author: Bob Swift (personal)
body: Was there any resolution to this? The link is broken.


author: David Peterson
body: It's possible with Composition 3 for Confluence 4.x. It should add a #anchor for each tab, which will also work coming into the page directly.

comments: author: Fabian Lopez
body: Thanks david that is the one I am using.

I enter an anchor on the body of card and then a link to that anchor but it is not working.... I will test it again.


author: Fabian Lopez
body: I tried adding an #anchor on each card, in the first line of the card box.

then I created links to that anchor, the address bar is changing as I click on each of the links but the tab is not opening. When I click on the link that is for the active card/tab the body of the moves up having the top of the screen where the anchor is. This works only with the tab that is open in that moment


Tags: card

deck-of-cards