Jeff VIP
Total posts: 745
04 Nov 2014 08:43

Hi,

wouldn't it be nice if links had a (meta) description in the url field? Currently, the label/title is automagically recognised when you enter a url. The meta description of the url page could be retrieved in a similar way. Adding a description field would make the url field even more versatile than it already is.

What do you think?

Best regards, Jeff

Last Modified: 13 Apr 2018


Konstantin
Total posts: 1,113
04 Nov 2014 10:53

About what meta description are you talking?


Jeff VIP
Total posts: 745
04 Nov 2014 11:45

Meta descriptions are HTML attributes that provide concise explanations of the contents of web pages. Meta descriptions are commonly used on search engine result pages (SERPs) to display preview snippets for a given page.

http://moz.com/learn/seo/meta-description

Although it would be nice to capture the meta description of a page/site automatically, it would be better if you could add your own.


Konstantin
Total posts: 1,113
04 Nov 2014 12:17

And what with this description do?


Jeff VIP
Total posts: 745
04 Nov 2014 12:46

Ok,

Instead of two fields per url:

I want three fields per url:

  • url ( http://www.mintjoomla.com )
  • label (MintJooomla)
  • description (MintJoomla is the new brand name from Mighty Technologies Pvt. Innovative, professional Joomla! Components for business solutions)

Konstantin
Total posts: 1,113
05 Nov 2014 05:07

How I understand you want one more field on form to input your own description or getting it from the site. And show it in full/list view or using it something else more?


Jeff VIP
Total posts: 745
05 Nov 2014 05:24

Konstantin How I understand you want one more field on form to input your own description or getting it from the site. And show it in full/list view or using it something else more?

Correct


Sergey
Total posts: 13,748
06 Nov 2014 11:15

We call it subform. Some also call multi fields. This is field we are pluning to create for Cobalt 9. Right now you can only make copy of URL field and hack it.


Jeff VIP
Total posts: 745
06 Nov 2014 11:32

Sergey We call it subform. Some also call multi fields. This is field we are pluning to create for Cobalt 9. Right now you can only make copy of URL field and hack it.

Ok, I see.

I think hacking the url field (adding a input field) is a bit too complicated for me.

However, can I retrieve the url and label seperately?

I want to create something in this order:

  1. label
  2. description
  3. url

Sergey
Total posts: 13,748
06 Nov 2014 11:38

Yes. It saves data as array. I am sure if you look into code you will find it possible. As far as I know your skill I am almost sure you will be able to do it.


Jeff VIP
Total posts: 745
06 Nov 2014 11:47

Sergey Yes. It saves data as array. I am sure if you look into code you will find it possible. As far as I know your skill I am almost sure you will be able to do it.>

It seems that you know me better than I know myself, Master Sergey ;-)


klox7 VIP
Total posts: 914
06 Nov 2014 11:48

@Jeff why don't you try copy url field and add new parameter for description in xml. Then add new input in input template and display this parameter in output template. I just don't know how new parameters are saved, I mean I don't know if you have to code "save" action somehow.


Jeff VIP
Total posts: 745
06 Nov 2014 12:00

klox7 @Jeff why don't you try copy url field and add new parameter for description in xml. Then add new input in input template and display this parameter in output template. I just don't know how new parameters are saved, I mean I don't know if you have to code "save" action somehow.

Yes thank you, that crossed my mind.

But the tricky part is saving the new parameter into the array (label, description, url).


Sergey
Total posts: 13,748
06 Nov 2014 12:07

No need to change any logic and save.

  1. Change input template. In line 31 it adds block of fields. Add there another parameter.
  2. Now change assets/url.js and its createBlock function. Add one more field there.

That should be it.

  1. In output template now use another field to disaply its value.

Jeff VIP
Total posts: 745
06 Nov 2014 12:23

Exciting!

I'll get on with it then and keep you updated.

Thanks.


Jeff VIP
Total posts: 745
06 Nov 2014 14:29

Hi Sergey,

as usual you make things sound easier than they are, but you gave me (just) enough directions to solve this puzzle :-)

I had to alter the code in many more places than you described.....

Thanks!


Jeff VIP
Total posts: 745
06 Nov 2014 15:00

BTW,

I still don't know how to show one value of the array of a url field in the record template.

I tried $item->fields_by_key['key']->value['description'] but nothing is displayed.


klox7 VIP
Total posts: 914
06 Nov 2014 15:15

maybe params->get('description')


Jeff VIP
Total posts: 745
06 Nov 2014 15:38

Nothing with $item->fields_by_key['key']->params->get('description')


Konstantin
Total posts: 1,113
07 Nov 2014 03:11

Have you add description field on form and save something?


Jeff VIP
Total posts: 745
07 Nov 2014 05:54

Konstantin Have you add description field on form and save something?

Yes, I followed Sergey's instructions. However after doing some tests, there is a big concern:

The description field (as part of the url field) needs to be protected from malicious input (javascript, php) and stripped from html. I also need an input limit set for the maximum amount of characters allowed.

If I'd use a standard text or textarea field, these concerns would all have been addressed. But because I've added a custom input textarea into a non-text field, I have to write a lot of code to protect it.

At one point I have managed to make the input fields disappear completely on the form after pasting raw html from another web page. It resulted in all sorts of errors. Adding code to strip newlines and html from the input, didn't solve the copy /paste issue either.

My best and savest option is to use a standard textarea field for the description and figure out how to put this between the label and the url of the url field, hence my question how to render the label and url seperately.

Powered by Cobalt