Page 1 of 1

[SOLVED] Is there a tag for inserting an anchor?

Posted: Thu Jan 08, 2009 9:06 pm
by eh
Till now I missunderstood the {anchor} tag. Thought it serves for placing the '' in the generated HTML, but actually it creates a link targetting the anchor.
Figured out that I have to insert the anchor with the TinyMCE editor. What I'd like more would be something readable in the form of a tag, for example {insert_anchor name="myanchor"}.

My question now is: Does such a tag exist somewhere and does it make any sense at all to have such a tag?

Thanks
Ernst

Re: Is there a tag for inserting an anchor?

Posted: Thu Jan 08, 2009 9:37 pm
by christiaans
This is done fairly easy actually.

Go to Extensions > User Defined Tags (usually referred to as UDT), and create a new UDT, with the following:

Code: Select all

echo '<a name="' . $params['name'] . '" title="'' .$params['name']"></a>';
Then insert your UDT as follows (if you call your UDT "insert_anchor"):

Code: Select all

{insert_anchor name="anchorname"}
If you don't know how to do this, take a look at the wiki page about UDT's:
http://wiki.cmsmadesimple.org/index.php ... fined_Tags

Re: Is there a tag for inserting an anchor?

Posted: Thu Jan 08, 2009 10:01 pm
by eh
Thank you!

I've put it in the collection of UDT's here:

http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here#Inserting_an_anchor_in_generated_HTML

Maybe others are also interested in it.
Regards
Ernst

Re: [SOLVED] Is there a tag for inserting an anchor?

Posted: Fri Jan 09, 2009 6:46 am
by christiaans
Awesome! Good luck with your site :)..

Re: [SOLVED] Is there a tag for inserting an anchor?

Posted: Sun Jan 18, 2009 5:04 pm
by faglork
No need for an UDT here  ... there is already a tag available for that: cms_selflink
Just look into the tag help for parameters.

Cheers,
Alex

Re: [SOLVED] Is there a tag for inserting an anchor?

Posted: Sun Apr 05, 2009 6:38 pm
by eh
Hi Alex

I read the cms_selflink documentation over and over and tried it out - but didn't succeed with using it to create an anchor in a page. For me the cms_selflink tag is indeed used to create a visible link in a page users can click on to be transferred to another page or location within the same page. Creating a link to anchor "demoanchor" in page "references" is done like this:

{cms_selflink dir="anchor" page="references" anchorlink="demoanchor" text="Click here..."}

So this wasn't my problem - but I didn't find something pre-fabricated in CMSMS to create the (invisible) anchor which should look like this for the example given above:

Blablabla...
...more blablabla

If you could show me how this is achieved with cms_selflink I'd be very thankful because I prefer using existing components instead of writing my owns.

Regards
Ernst

Re: [SOLVED] Is there a tag for inserting an anchor?

Posted: Mon Apr 06, 2009 12:41 pm
by faglork
Ah, I misread the post.

Creating an anchor is simple:

a) TinyMCE has an "Anchor" button. It will insert a

Code: Select all

<a name="zzz"></a>
code.

b) Since you can reference class IDs as well, you just assign an ID to the element which shall serve as  anchor. E.g. you can reference

Code: Select all

#header
  if you want a "Back to top of page" anchor link.

c) last not least there is the

Code: Select all

{anchor}
tag:
http://forum.cmsmadesimple.org/index.ph ... 210.0.html


Cheers,
Alex

Re: [SOLVED] Is there a tag for inserting an anchor?

Posted: Wed Apr 08, 2009 2:47 pm
by eh
Hi Alex

a)

Using WYSIWYG mode in TinyMCE shows a small anchor icon for every anchor in a page - one has to select the icon to see the anchor name. Because I have a page with several anchors it's easier for me to read if I see the anchor names in the text, embedded in the {} for my UDT:

Code: Select all

* [Cla94] {insert_anchor name='cla94'} Clarkson, Mark, Windows hothouse: creating artificial life with Visual C++, Addison Wesley, 1994.
* [Ted07] {insert_anchor name='ted07'} Thoughts by Ted (Internet).
* [Wri00] {insert_anchor name='wri00'} Wright, Richard S., Jr., OpenGL Super Bible, Second Edition, Waite Group Press, 2000.

...
...


b)

Yes, works great (http://forum.cmsmadesimple.org/index.php/topic,30210.0.html). But here too I can't easily figure out the anchor name.

c)

{anchor} creates a link targeting at an anchor, similar to {cms_selflink} but as far as I understand without capability to link to anchors on other pages.

Regards
Ernst