Getting Port Number with Domain Name

aeryaery Gtricks Forum in 2.2 :) ✭✭✭

Context:
I am trying to develop my Vanilla plugin and using function .$this->Data('Discussion.Url').' to get the canonical URL of the discussion.

**Problem: **
I am getting default port number 80 with that code. Example: www.domain.com:80/discussion/post-title

Platform:
Shared hosting so LAMP. Vanilla 2.1b

Solution?

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Depends how you want to approach it. You could a) parse $this-Data('Discussion.Url') or b) get the data elsewhere and assemble it.

    a) Use PHP's parse_url() function $this-Data('Discussion.Url') and return reassemble it sans port:

    $url parse_url($this-Data('Discussion.Url'));
    
    echo $url['host'].$url['path'];
    

    b) This can be left as an exercise for someone else. ;D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    UnderDog
  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    wow wow wow. You are genius. Thanks a lot.

    UnderDog
  • peregrineperegrine MVP
    edited June 2013

    @hgtonight said
    b) This can be left as an exercise for someone else. ;D

    </p> <pre> $canonical = $Sender->CanonicalUrl(); $canonical = preg_replace("|\/p\d?|","",$canonical); // remove page number echo $canonical . "<br>"; </pre> <p>

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDogaeryhgtonight
  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    wow wow wow again. You are awesome :)

  • @aery said:
    wow wow wow again. You are awesome :)

    Maybe I'll get a wow-wow-wow (and lol reactions) plugin. So you can click wow instead of saying it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    vrijvlinderaery
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    yes words are fickle but the clicks on (awesome) show true sincerity !!

Sign In or Register to comment.