antonyfal Posted July 4, 2011 Share Posted July 4, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/ Share on other sites More sharing options...
antonyfal Posted July 4, 2011 Author Share Posted July 4, 2011 Hi Pikachu, I see why you moved this to Javascript.. But i think it is a mix problem-- I can get the from php and echo it into the place of the above , I more hurst on php then javascript... Is there no function to pull the page title in php? and by the way this moved itself back to the php forum... i think? Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/#findComment-1238268 Share on other sites More sharing options...
antonyfal Posted July 4, 2011 Author Share Posted July 4, 2011 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 --> ?> Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/#findComment-1238339 Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2011 Share Posted July 4, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/#findComment-1238347 Share on other sites More sharing options...
antonyfal Posted July 5, 2011 Author Share Posted July 5, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/#findComment-1238479 Share on other sites More sharing options...
antonyfal Posted July 5, 2011 Author Share Posted July 5, 2011 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 --> '; } Quote Link to comment https://forums.phpfreaks.com/topic/241071-building-a-url-from-explode-function-and-getting-page-title-to-make-new-url/#findComment-1238515 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.