Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-13 04:01:47

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

[request] generated links

I was wondering if anyone would be able to make a plugin that would allow an user to create links in the admin panel and use the tags instead of using HTML to create links in a page or form. For example:

HTML format: <a href=“http://domain.com”>domain</a>

Plugin tag format: <txp:whatever format=“a”… />

I don’t know how it can be done but you get my idea…

As of now, to create additional links not related to TXP in a page or form, I have to use the HTML format but I thought using a simple tag would make it a lot easier.


<txp:Ruhh />

Offline

#2 2008-05-13 06:50:03

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: [request] generated links

I’m not sure exactly what you’re asking for here. A tag that would return an anchor link as you describe would be fairly simple to code, but it would require that you pass the tag an href attribute and any class, id, or style values that you would might need. Coding the tag into the template would become more complex than coding the anchor link, and less flexible.

Offline

#3 2008-05-13 14:58:31

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [request] generated links

Yes, that is what I would want. For example, the feed link. There is already a tag for the feed link so an user will not have to create it using HTML but just using the tag. So I was hoping something like that could be made for any other links where an user create any link in the admin panel and the tag gets the name or id for the specified link.


<txp:Ruhh />

Offline

#4 2008-05-13 15:49:35

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: [request] generated links

i’m not sure if i’m getting this right but do you want to define a list of URIs/shortcut pairs that can then be called with a tag, like a shortcut? so you would maybe define “flickr”->http://flickr.com/photos/foobar and then, everytime you want to link to your flickr photos, it would be sufficient to use <txp:mylink name="flickr" /> — is that what you’re aiming for? that could be done very easily if you’re not afraid of storing some values in the plugins code…

Offline

#5 2008-05-13 15:50:19

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: [request] generated links

Linklist is what is used to call links from the links admin panel. The intention there is a blogroll style list of links and the choice isn’t available with that tag to call a link singly by ID. If calling a link from the links table individually by ID is what you are looking for, that choice should be workable either by writing a new tag or reworking an existing one (I would have to look at that possibility). Give me some time and I’ll see what I can come up with.

Offline

#6 2008-05-13 16:20:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: [request] generated links

Ruhh wrote:

I was wondering if anyone would be able to make a plugin that would allow an user to create links in the admin panel and use the tags instead of using HTML to create links in a page or form. For example:

HTML format: <a href=“http://domain.com”>domain</a>

Plugin tag format: <txp:whatever format=“a”… />

I don’t know how it can be done but you get my idea…

As of now, to create additional links not related to TXP in a page or form, I have to use the HTML format but I thought using a simple tag would make it a lot easier.

Isn’t textile enough?

"domain":http://www.domain.com


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2008-05-13 16:56:04

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: [request] generated links

The process with Textile is probably your best option. The difficulty with using a tag in the template has to do with getting the information from the admin panel to set your tag. Writing the tag definition, if you are drawing from the links table, would involve a database query. Even were the tag definition built, using it would still be more cumbersome than a Textile link or straight forward HTML. In the end, as the demands on your HTML links become more sophisticated, the limitations imposed by the hard-coded tag definition would make it more trouble than it’s worth. I’m guessing that is why it hasn’t been done already.

Offline

#8 2008-05-13 19:20:36

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [request] generated links

sthmtc: yes, that is exactly what i want.

colak: i am not looking forward to use them in an article but in a page template and/or forms.

rsilletti: having a tag created along the attribute id=”##” created from the links tab in admin would be a good idea. because I wouldn’t need a list but individual ones.


<txp:Ruhh />

Offline

#9 2008-05-13 19:42:02

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: [request] generated links

Ruhh wrote:

colak: i am not looking forward to use them in an article but in a page template and/or forms.

you could always wrap upm_textile around the blocks in question…

Last edited by sthmtc (2008-05-13 19:42:15)

Offline

#10 2008-05-13 19:52:12

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [request] generated links

Sounds like an useful plugin but still I would like something similiar to the feed url. So I can just use one small tag.


<txp:Ruhh />

Offline

#11 2008-05-13 22:08:16

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: [request] generated links

Ruhh – try plugging this in and tell me if this is what you are thinking about. The plugin contains three tags: ras_singlelink (which returns a linked with the linkname and url associated with the link id) att would be “link_id”.
ras_singlelinkname (which returns name only) att would be “link_id”.
ras_singlelinkurl (which returns the url as text) att would be ‘link_id”.

Bear in mind that these tags are a little rough and untested and there isn’t a help file yet, but if they are found to be useful I will polish them up and make them presentable.

Let me know what you think. (anyone who would like to test is welcome)



# ras_singlelink 0.1

# Single link set from link ID

# raas

# http://textcastle.com



# .....................................................................

# This is a plugin for Textpattern - http://textpattern.com/

# To install: textpattern > admin > plugins

# Paste the following text into the 'Install plugin' box:

# .....................................................................



YTo5OntzOjQ6Im5hbWUiO3M6MTQ6InJhc19zaW5nbGVsaW5rIjtzOjY6ImF1dGhvciI7czo0OiJyYWFzIjtzOjEwOiJhdXRob3JfdXJpIjtzOjIxOiJodHRwOi8vdGV4dGNhc3RsZS5jb20iO3M6NzoidmVyc2lvbiI7czozOiIwLjEiO3M6MTE6ImRlc2NyaXB0aW9uIjtzOjMzOiJTaW5nbGUgbGluayBmcm9tIHNldCBmcm9tIGxpbmsgSUQiO3M6NDoiaGVscCI7czoxNjoiKmluIGRldmVsb3BtZW50KiI7czo0OiJjb2RlIjtzOjExMzQ6IiBmdW5jdGlvbiByYXNfc2luZ2xlbGluaygkYXR0cykNCgl7DQoJCWV4dHJhY3QobEF0dHMoYXJyYXkoDQoJCQknbGlua19pZCcgPT4gJycsDQoJCQknY2xhc3MnID0+IF9fRlVOQ1RJT05fXw0KCQkpLCRhdHRzKSk7DQogICAgICAgICAgICAgICAgJHJlc3VsdCA9IHNhZmVfcm93c19zdGFydCgnKicsICd0eHBfbGluaycsICJJRCA9ICRsaW5rX2lkIik7DQoJCQkJCXdoaWxlKCRhID0gbmV4dFJvdygkcmVzdWx0KSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkb3V0ID0gaHJlZigkYVsnbGlua25hbWUnXSAsICRhWyd1cmwnXSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KCQlyZXR1cm4gJG91dDsNCgl9DQoNCiBmdW5jdGlvbiByYXNfc2luZ2xlbGlua25hbWUoJGF0dHMpDQoJew0KCQlleHRyYWN0KGxBdHRzKGFycmF5KA0KCQkJJ2xpbmtfaWQnID0+ICcnLA0KCQkJJ2NsYXNzJyA9PiBfX0ZVTkNUSU9OX18NCgkJKSwkYXR0cykpOw0KICAgICAgICAgICAgICAgICRyZXN1bHQgPSBzYWZlX3Jvd3Nfc3RhcnQoJyonLCAndHhwX2xpbmsnLCAiSUQgPSAkbGlua19pZCIpOw0KCQkJCQl3aGlsZSgkYSA9IG5leHRSb3coJHJlc3VsdCkpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJG91dCA9ICRhWydsaW5rbmFtZSddOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCgkJcmV0dXJuICRvdXQ7DQoJfQ0KDQoNCiBmdW5jdGlvbiByYXNfc2luZ2xlbGlua3VybCgkYXR0cykNCgl7DQoJCWV4dHJhY3QobEF0dHMoYXJyYXkoDQoJCQknbGlua19pZCcgPT4gJycsDQoJCQknY2xhc3MnID0+IF9fRlVOQ1RJT05fXw0KCQkpLCRhdHRzKSk7DQogICAgICAgICAgICAgICAgJHJlc3VsdCA9IHNhZmVfcm93c19zdGFydCgnKicsICd0eHBfbGluaycsICJJRCA9ICRsaW5rX2lkIik7DQoJCQkJCXdoaWxlKCRhID0gbmV4dFJvdygkcmVzdWx0KSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkb3V0ID0gJGFbJ3VybCddOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCgkJcmV0dXJuICRvdXQ7DQoJfSI7czo0OiJ0eXBlIjtzOjE6IjAiO3M6MzoibWQ1IjtzOjMyOiIzZjAwMGRiYTdkMDkzN2JkNWYzOTQzNGUwNzQyY2MxYSI7fQ==

Offline

#12 2008-05-13 23:39:15

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [request] generated links

Works great. In debugging mode and no errors to be found.


<txp:Ruhh />

Offline

Board footer

Powered by FluxBB