Jump to content

building a url from explode function and getting page title to make new url?


Recommended Posts

Hi, As i see it this should be an easy one..

Im using the addthis shareing script to share a page url on multiple platforms...

My problem is that i have sef urls and also a seperate fast search page where profiles are called up via search. These profiles are called in an iframe and the url is then notadd sef any longer but the standard url...

 

What i need to do is build the sef url from the server request uri and then add the page title which is also the profiles name to the new url---

 

i can do everything to build the url, but i do not know how to pull the page title? one thing to note is that the page being shared is in an Iframe, i dont think this is a big problem as the script to share is also on the page which appears in the iframe..

 

here is the addthis shareing script which calls to the url:

 

<!-- AddThis Button BEGIN -->

<script type="text/javascript">addthis_pub  = \'davidp13\';</script>

<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \'\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-addthis.gif" width="125" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>

<!-- AddThis Button END -->

';

}

 

here is an example of the url and the result i need for the sef url equivalent:

current link no sef

http://www.xxxxxxxxx.com/subfolder/index2.php?option=xxxxxx&Itemid=1&task=viewprofile&profileid=1

 

Sef result needed to fill the above:

http://www.xxxxxx.com/subfolder/viewprofile/profilesownersname/1.html

 

the "1" is the profile owners profile id i can pull this from the url above, the viewprofile is a standard word in the url, but the profile owners name is by default also the PAGETITLE.

which doesn't show in the non sef link..

 

any ideas how to pull the pagetitle and add it to the new url before it is passed?

best regards

Antony

Hi i have found a work around to this problem above:

how can i get the php to echo the url in the javascript? the php is not echoing the newly created url!? am i missiing something here please help if you can..

regards

 

<?php

        $currenturl = $_SERVER['REQUEST_URI'];

        $newurl = explode("/", $url);

        $url2 = $_SERVER['HTTP_HOST'];

        $myurls = 'http://'.$url2.'/'.$newurl[1].'/'.viewprofile.'/'.$profile_name.'/'.$profile_id.'.'.html;

echo '<br/>

<!-- AddThis Button BEGIN -->

<script type="text/javascript">addthis_pub  = \'davidp13\';</script>

<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \'<?php echo $myurl;\?>', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-addthis.gif" width="125" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>

<!-- AddThis Button END -->

?>

You're already within php tags when you try to echo $myurl, so the <?php echo . . . ?> isn't necessary. I don't see where you're getting the title from, though. Isn't that what the problem was?

Hi, getting the title proved too much work.. The title is also the $profile_name, so as i had the code to get the current profile name, i used that to build the SEF URL.. as i see it it should work...

 

the title is called from the addthis sharing .js file... but my java is useless, so to try to fit that into the new url is weeks of work for me...

 

The echo didnt work by the way, the reason being the original is an output from the javascript. Pikachue was correct i got to move this question to the javascript forum..

 

If you would like a crack at it i can post the javascript here or msg you?

Thanks for the reply.

Antony

Solved it: so stupid!! the $myurls is already echoed in the html.. :) its the little things that make the big difference...

 

heres the fix!!

 

 

        $currenturl = $_SERVER['REQUEST_URI'];

        $newurl = explode("/", $currenturl);

        $url2 = $_SERVER['HTTP_HOST'];

        $myurls = 'http://'.$url2.'/'.$newurl[1].'/'.viewprofile.'/'.$profile_name.'/'.$profile_id.'.'.html;

 

// here the html is already echoed.. so was not neccessary to put the php or the echo!! Thanks for the help..

echo '<br/>

<!-- AddThis Button BEGIN -->

<script type="text/javascript">addthis_pub  = \'davidp13\';</script>

<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \''.$myurls.'\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-addthis.gif" width="125" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>

<!-- AddThis Button END -->

';

}

 

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.