Project

General

Profile

Custom Fields - how to style URLs?

Added by Christopher Semmler 3 months ago

What I try to achieve:

Each project has custom fields attached that link to a certain folder in our Nextcloud. These links look like this:

https://cloud.domain.tld/apps/files/<random string>/<folder name>

I have read through the documentation for RedmineCustomFields for adding custom fields with links to projects. I am trying to customise the custom field in a way that only the <folder name> is shown in the output, while the <random string> remains invisible. I have set the configuration to link the input value to an URL appended with %value%, so that works fine. It just sucks that the value itself is visible, including the <random string> part.

Example:
Custom field name: Folder
Input value: 12345?dir=/Folder-Name
Displayed text: 12345?dir=/Folder-Name

How could I configure these custom fields to still link to the correct URL but only show Folder-Name in the project? I tried to experiment with the Regex input, but it seems I am too stupid to do that.


Replies (7)

RE: Custom Fields - how to style URLs? - Added by Bernhard Rohloff 3 months ago

Hi Christopher,

have a look at this section in the custom fields documentation: RedmineCustomFields
I think it's exactly what you are looking for.

Greetings,
Bernhard

RE: Custom Fields - how to style URLs? - Added by Christopher Semmler 3 months ago

have a look at this section in the custom fields documentation: RedmineCustomFields

Thanks for your reply. This part worked out as stated in my initial message. I have defined the URL part with input value 12345?dir=/Folder-Name being appended by %value%, thus the result is being interpreted as https://cloud.domain.tld/apps/files/%value%.

My problem is being too stupid to set the Regex correctly in order to append %m1%, %m2% instead of %value%, m1 being @12345?dir=/ and %m2% being Folder-Name.

RE: Custom Fields - how to style URLs? - Added by Christopher Semmler 3 months ago

Christopher Semmler wrote in RE: Custom Fields - how to style URLs?:

have a look at this section in the custom fields documentation: RedmineCustomFields

Edit: I have no clue how to edit comments here, thus the correction added here:

- My problem is being too stupid to set the Regex correctly in order to append %m1%, %m2% instead of %value%, m1 being @12345?dir=/ and %m2% being Folder-Name.

+ My problem is being too stupid to set the Regex correctly in order to append %m1%, %m2% instead of %value%, %m1% being 12345?dir=/ and %m2% being Folder-Name.

RE: Custom Fields - how to style URLs? - Added by Bernhard Rohloff 3 months ago

Oh yeah now I see it. Sorry, I didn't read your post word for word.
Your problem gets a bit tricky there. You cannot influence the form the input values of the custom field are displayed. The regex is mainly used to check the format of the input value and can be used to extract parts used by the URL. It does not affect the display of the value itself.
What you could do is to use the 'long text' field instead of the normal one. The advantage of the 'long-text' field is that you can add formatting like in the wiki pages. Then you can create the link with whatever text you like to display.

RE: Custom Fields - how to style URLs? - Added by Lorenzo Meneghetti 3 months ago

Bernhard Rohloff wrote in RE: Custom Fields - how to style URLs?:

Your problem gets a bit tricky there. You cannot influence the form the input values of the custom field are displayed. The regex is mainly used to check the format of the input value and can be used to extract parts used by the URL. It does not affect the display of the value itself.

If you are interested and if you have the ability to edit redmine code, a few years ago I wrote a new method that allows you to do exactly what you ask. It seemed like a missing feature. In the end I didn't publish the patch because I had no time to write the test method too. :-)
If you are interested I'll share it here.

RE: Custom Fields - how to style URLs? - Added by Bernhard Rohloff 3 months ago

Lorenzo Meneghetti wrote in RE: Custom Fields - how to style URLs?:

...
If you are interested and if you have the ability to edit redmine code, a few years ago I wrote a new method that allows you to do exactly what you ask. It seemed like a missing feature. In the end I didn't publish the patch because I had no time to write the test method too. :-)
If you are interested I'll share it here.

At least, it would be cool to see the solution. This could be nice feature.

RE: Custom Fields - how to style URLs? - Added by Lorenzo Meneghetti 2 months ago

Hi Bernhard,

At least, it would be cool to see the solution. This could be nice feature.

Finally find time to post a patch for this.

Thanks

    (1-7/7)