HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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?

There was an error rendering this rich post.

Comments

  • Options
    hgtonighthgtonight ∞ · New MVP

    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.

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

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

    There was an error rendering this rich post.

  • Options
    peregrineperegrine MVP
    edited June 2013

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

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

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

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

    wow wow wow again. You are awesome :)

    There was an error rendering this rich post.

  • Options

    @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.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

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

Sign In or Register to comment.