Jump to content

change a dynamic url for pintrest pinning


pbucc

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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): ?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.