pbucc Posted August 24, 2015 Share Posted August 24, 2015 hi eveyone, i have a site that users can post images of material before it was just my site url/client/postnumber example: http://www.slabber.ca/view/stone/1509 . now i have the clients under a subdomain and it post's like this http://milestone.slabber.ca/view/stone/1509 . i need some help adding the client name in front of the domain for posting to pintrest, facebook and twitter. here is the code: <div id="social"> <a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fslabber.ca<?php echo urlencode(uurl('view/stone/' . $this->stone->id, true)); ?>&media=http%3A%2F%2Fslabber.ca<?php echo urlencode(url(Stock::image(User::id(true), $this->stone->id, 'originals'), true)) ?>&description=<?php echo urlencode(ucwords(strtolower($this->stone->name)) . ' '.ucwords(strtolower($this->stone->category)).' '.($this->stone->is_remnant ? 'remnant' : 'slab') .' sold by ' . $this->user->business . ' | Size: ' . str_replace('inch', '', str_replace('cm', '', str_replace('inches', '', Stock::dimensions($this->stone->width, $this->stone->height, $this->user->use_imperial)))) . ' x ' . Stock::thickness($this->stone->thickness, $this->user->use_imperial)) ?>" class="pin-it-button" count-layout="horizontal"> <img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /> </a> <div class="fb-like" data-href="http://slabber.ca<?php echo uurl('view/stone/' . $this->stone->id, true); ?>" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false" data-font="arial"></div> <a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php echo (ucwords(strtolower($this->stone->name)) . ' ('.ucwords(strtolower($this->stone->category)).') sold by ' . $this->user->business) ?>" data-lang="en" data-url="http://slabber.ca<?php echo uurl('view/stone/' . $this->stone->id, true) ?>" data-count="horizontal" data-via="slabbercms">Tweet</a> <?php if (!$this->small): ?> any help would be great. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted August 24, 2015 Share Posted August 24, 2015 You have your domain hard set, so all you need to do is replace those areas using parse_url() from the source url and find the host. parse_url($url, PHP_URL_HOST) Quote Link to comment Share on other sites More sharing options...
pbucc Posted August 24, 2015 Author Share Posted August 24, 2015 You have your domain hard set, so all you need to do is replace those areas using parse_url() from the source url and find the host. parse_url($url, PHP_URL_HOST) can you give me an example from the code i supplied. this was done by someone and now i can find anyone to help. you would be only accessing the pintrest, facebook, and twitter from the posted url: http://milestone.slabber.ca/view/stone/1509. i am learning php but that great at it. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted August 25, 2015 Share Posted August 25, 2015 If you are getting these values from a database can do something like this. $host = parse_url($src_url_from_database, PHP_URL_HOST); If this script runs each subdomain can use $_SERVER['SERVER_NAME'] Not sure what the uurl function does or how this works in your code without a slash between the host and directory <div id="social"> <a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2F<?php echo $_SERVER['SERVER_NAME'] . urlencode(uurl('view/stone/' . $this->stone->id, true)); ?>&media=http%3A%2F%2F<?php echo $_SERVER['SERVER_NAME'] . urlencode(url(Stock::image(User::id(true), $this->stone->id, 'originals'), true)) ?>&description=<?php echo urlencode(ucwords(strtolower($this->stone->name)) . ' '.ucwords(strtolower($this->stone->category)).' '.($this->stone->is_remnant ? 'remnant' : 'slab') .' sold by ' . $this->user->business . ' | Size: ' . str_replace('inch', '', str_replace('cm', '', str_replace('inches', '', Stock::dimensions($this->stone->width, $this->stone->height, $this->user->use_imperial)))) . ' x ' . Stock::thickness($this->stone->thickness, $this->user->use_imperial)) ?>" class="pin-it-button" count-layout="horizontal"> <img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /> </a> <div class="fb-like" data-href="http://<?php echo $_SERVER['SERVER_NAME'] . uurl('view/stone/' . $this->stone->id, true); ?>" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false" data-font="arial"></div> <a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php echo (ucwords(strtolower($this->stone->name)) . ' ('.ucwords(strtolower($this->stone->category)).') sold by ' . $this->user->business) ?>" data-lang="en" data-url="http://<?php echo $_SERVER['SERVER_NAME'] . uurl('view/stone/' . $this->stone->id, true) ?>" data-count="horizontal" data-via="slabbercms">Tweet</a> <?php if (!$this->small): ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.