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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
eh
Forum Members
Forum Members
Posts: 29
Joined: Sun Oct 07, 2007 1:19 pm

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

Post 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
Last edited by eh on Thu Jan 08, 2009 10:02 pm, edited 1 time in total.
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: Is there a tag for inserting an anchor?

Post 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
Last edited by christiaans on Thu Jan 08, 2009 9:39 pm, edited 1 time in total.
eh
Forum Members
Forum Members
Posts: 29
Joined: Sun Oct 07, 2007 1:19 pm

Re: Is there a tag for inserting an anchor?

Post 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
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

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

Post by christiaans »

Awesome! Good luck with your site :)..
faglork

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

Post 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
eh
Forum Members
Forum Members
Posts: 29
Joined: Sun Oct 07, 2007 1:19 pm

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

Post 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
faglork

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

Post 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
Last edited by faglork on Mon Apr 06, 2009 12:43 pm, edited 1 time in total.
eh
Forum Members
Forum Members
Posts: 29
Joined: Sun Oct 07, 2007 1:19 pm

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

Post 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
Post Reply

Return to “CMSMS Core”