You are viewing limited content. For full access, please sign in.

Question

Question

Custom HTML (URLs) within Collections

asked on September 18, 2018 Show version history

I have a collection. Within that collection, I capture the WebLink URL through Workflow. That's working beautifully. In my example, I have queried Laserfiche and obtained three different WebLink URLs.

The issue is trying to get that URL to be a hyperlink within the collection. When I try creating a custom HTML, I get all three showing instead of one at a time.

So the question is this, how do I create a hyperlink within a collection so the user can click on it to view the document? This is what I'd like to see:

Ideas?

0 0

Answer

SELECTED ANSWER
replied on September 18, 2018 Show version history

I saw your other post. You just used the variable directly in your custom HTML element... something like this:

<a href="{dataset/supplierDocs/sdsLink}">

The trouble is, the variable will give you a delimited list of all the values in this sort of situation. Since you already have each link broken out the way you want in the hidden fields, what you need is to use some javascript that updates the custom HTML with the link from it's own collection block section after the page loads all the data. Give your hidden URL field a CSS class, like hiddenURL, and also give the link element in your custom HTML a CSS class like this:

<a class="myLink" href="">

Then on the form load, loop over each collection block and run some javascript to use your hidden field to set the href attribute on the <a> tag in the same block:

$(document).ready(function(){
  $('.cf-collection > div.form-q').each(function(){
    $(this).find('.myLink').prop('href',$(this).find('.hiddenURL input').val());
  });
});

EDIT: Updated the JS to fix an error based on the comment below.

0 0
replied on September 18, 2018

It didn't work. Did I dot my "i's" and cross my "t's" OK?

I added the hiddenURL to my sdsLink field:

This is what's now in my custom HTML:

<font size="4">
<p align="center">
<a class="myLink" href="">Click this link to view the supplier document: </a>
</p>
</font>

And I added the following JavaScript:

$(document).ready(function(){

//Loops over each collection block and uses  hidden field to set the href attribute on the <a> tag in the same block
  $('.cf-collection > div.form-q').each(function(){
    $(this).find('.myLink').prop('href',find('.hiddenURL input').val());
  });

});  //close document.ready

Here's what I'm getting for a result:

I temporarily show the sdsLink field to make sure all three are still unique. They are.

0 0
replied on September 18, 2018 Show version history

My Bad! The problem is in the original Javascript (that's what I get for posting without testing).

Your line 5 should read:

 $(this).find('.myLink').prop('href',$(this).find('.hiddenURL input').val());

I edited the original reply above too.

0 0
replied on September 19, 2018 Show version history

Hmmm ... made that change .... same unsuccessful result.

UPDATE: Just figured out why! I changed "input" to "textarea" and it worked!

 $(this).find('.myLink').prop('href',$(this).find('.hiddenURL textarea').val());

Phew! Thanks for the help.

0 0
replied on September 19, 2018

Ah, didn't realize the link would be in a textarea... glad you spotted that, and glad it's working!

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.