Jump to content

Articles custom field for news source URL (truncated)


Maxxius

Recommended Posts

hi, could you help me on making such a custom field in pages.

that custom field would be for inputting the news source url of the original article that I've posted.

I wish to simply paste the url in the custom field area and I want the output to be shown under the article on the next line with url truncated so only domain name remain for example.

if full url is https://invisioncommunity.com/forums/forum/497-peer-to-peer-technical-support/
then https://invisioncommunity.com/ would be shown, but when you click on the link it would take to the full url https://invisioncommunity.com/forums/forum/497-peer-to-peer-technical-support/

?

For now I made a much simpler version here with a custom display format:

<i><a target="_blank" href="{$value}">Source</a></i>

value being the URL of source article

 

Link to comment
Share on other sites

Hello,

18 hours ago, Maxxius said:

I used URL but your code did not work,

For URL you should to use $formValue

$value return the formatted html

18 hours ago, Maxxius said:

By the way would you know any trick to remove the www. part from the



 
{{if mb_substr($urlhost['host'], 0, 4) === 'www.'}}
	{{$urlhost['host'] = mb_substr($urlhost['host'], 4);}}
{{endif}}

 

Link to comment
Share on other sites

2 hours ago, newbie LAC said:

Hello,

For URL you should to use $formValue

$value return the formatted html


{{if mb_substr($urlhost['host'], 0, 4) === 'www.'}}
	{{$urlhost['host'] = mb_substr($urlhost['host'], 4);}}
{{endif}}

 

Thanks but I'm unsure about $formValue part.

My code now looks like this and it works, yay

I added your change in " Display Custom Format "

{{$urlhost=parse_url($value);}}
{{if mb_substr($urlhost['host'], 0, 4) === 'www.'}}
	{{$urlhost['host'] = mb_substr($urlhost['host'], 4);}}
{{endif}}
<div class="ipsType_richText"><i>{$label}: <a target="_blank" href="{$value}">{$urlhost['host']}</a></i></div>

 

Link to comment
Share on other sites

1 minute ago, Maxxius said:

Thanks but I'm unsure about $formValue part.

format.thumb.jpg.3225c2edfa8535fd1c45dd90a6495457.jpg

2 minutes ago, Maxxius said:

I added your change in " Display Custom Format "

Add my code after {{$urlhost=parse_url($value);}}

{{$urlhost=parse_url($value);}}
{{if mb_substr($urlhost['host'], 0, 4) === 'www.'}}
	{{$urlhost['host'] = mb_substr($urlhost['host'], 4);}}
{{endif}}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...