Calling a URL from the Address Bar - php

I'm working on a link cloaker, and one of the features is the "Add This" social bookmark widget. It gives you the opportunity to define the URL that will be shared with this code:
<div class="addthis_toolbox addthis_default_style " addthis:url="THE URL">
As it's showing in a top frame, I want "THE URL" to be the URL in the address bar. As it is, it's only "sharing" the URL of the top frame in which it resides.
Here's the example:
http://1max.us/go/test
What bit of PHP could I replace "THE URL" with that would make it pick up the whole page, not just the top frame?

I got it to work. This is what did the trick:
<? echo $url="".$_SERVER['HTTP_REFERER']; ?>

Related

Codrops Thumbnail Grid reload data?

I have implemented the Codrops Expanding Preview script on a clients site. Everything is working great with the exception of one small glitch myself and team cannot figure out. We were able to customize the button text and add a new button ("Read Story" became LinkedIn which utilizes the href="" + we added Twitter which utilizes tag=""). Everything works well if you go from one item on the right and open another item on the left, but if you expand a preview on the left without a Twitter link and expand a preview on the right with a Twitter link - it saves the data from the previous expanded preview and does not show the Twitter link on the newly expanded preview because the other item did not have a Twitter link.
Here's the line of code showing the tag being utilized:
<a href="linked in url here" tag="#" data-largesrc="image url here" data-title="name here" data-description="description here ">
The tag="#" uses a # when there is no Twitter link.
In grid.js, we have added this to look for the # in the tag and have it display:none; -
if((eldata.tag).indexOf('#') >= 0) {
this.$tag.attr( 'style', 'display:none;' );
} else { this.$tag.attr( 'href', eldata.tag);
}
It seems to hold that value across all expanded previews and doesn't reload the data.
Is there any type of work around for this?

Redirection to facebook page

Well, my website can not redirect to
https://www.facebook.com/QuaFootSpa
from
http://quafootspa.com/
I have tried redirection to facebook page through
a tag href attribute and also javascript function. but it redirects to middle page. kindly browse http://quafootspa.com/ and click on facebook icon on the top so it will redirect to middle page that says Go To Facebook.com
Clicking on the (Go to Facebook.com) will direct to https://www.facebook.com/QuaFootSpa
Try target='_top' in the href.
So it becomes
<a target='_top' href="https://www.facebook.com/QuaFootSpa/">
Right now the link is being opened in the lower frame and FB doesnt like it.
Try <a href='http://www.facebook.com/QuaFootSpa/' target='_blank'>Facebook Page</a>
your putted https:// instead of http://
Tested and works.
You are using frame and in frame self works in the frame so use target="_top"
<img src="images/qspa/fb_btn.png">

Clicking hyperlink and go to a frame (new window), how to do it?

I am really knew to the frames; i have searched this questions in the internet but i didnt find any useful tutorials.
i have a website which shows links of other websites.currently i am not using any frames in my website. my website is made using php and code used for showing links is
echo("$rows['text'] </br>");
this code is working properly(when clicked the url will open in a new window).but what i want is to make a hyperlink like this website http://www.tutorialized.com/tutorial/Dreamweaver-Tutorials-Free-Dreamweaver-Web-Design-Tutorials-and-Resource/69843 . when click to "view tutorials" it should go to a webpage with my website name and ads on top and the the other website in bottom. I know that it can be done by frames but what i dont know is how to link my hyper link to a frame (only for showing urls).
what i understood so far is that.
echo("$rows['text'] </br>");
when an user click to this hyperllink it should go to web.php which is having below code.
<frameset rows="25%,75%">
<frame src="index.php" />
<frame src=<?php echo(".$rows['url']."?> /> <-- not sure about this code,i assumed that php can be inherited -->
</frameset>
but this code is not working. can any one tell me how i can hyperlink like the website "tutorialized.com" but in a new window.
Your link should be like:
echo("<a href='http://somedomain.com/web.php' target='theNameOfTheFrame'>$rows['text']</a> </br>");
But make sure that the name for the frame is theNameOfTheFrame.

loading external pages within website

I have a table in database which stores links submitted by users, I want my users to use those links whenever they want but the problem i am facing is
I can retrive and display the links with this code
<td width="560"><font color="#999">
'.$row['link'].'
</font>
</td>
but it generates link like this
http://XYZ.com/www.pxleyes.com/blog/2011/12/these-50-photos-will-blow-you-away/?action=tagtoload
so when the users click on this links it says page not found.
I want to open the links within my page so i have added ?action=tagtoload
which will load pages within my page with ajax call but the things are not working.
yes XYZ.com is my domain and for not generated links xyz.com/abc?action=tagtoload is working fine. its coming just below top header i want all external links to be below my header. can you please tell how i can open these links under my header. I want to display these links as anchored link so that user can see what these items are and when users clicks on these links it should open in iframe or whatever but under my header –
Guessing that XYZ.com stands for your domain:
add http:// for external links
Concerning the ajax-Problem:
Is it working with fixed, not generated links? Please post also the output of the php file and your ajax-code.
Please also define 'in you page': In an iframe? div? replacing your window?
EDIT:
To 'fix' you 'php-code':
<td width="560">
<font color="#999">
<a href="<?php print $row['link'] ?>?action=tagtoload" class="tagToload">
<?php print $row['link'] ?></a>
</font>
</td>
Please get familiar with html and php first.
do NOT use <font>, use css instead
use css instead of putting the width in the td as an attribute
read http://php.net/

Lightbox image / link URL

Basically I have a slightly non-standard implementation of FancyBox. By default you have to include a link to the large version of the image so that the Lightbox can display it. However, in my implementation, the image link URLs point to a script rather than directly to the image file. So for example, instead of:
<a href="mysite/images/myimage.jpg" rel="gallery">
I have:
<a href="mysite/photos/view/abc123" rel="gallery">
The above URL points to a function:
public function actionPhotos($view)
{
$photo=Photo::model()->find('name=:name', array(':name'=>$view));
if(!empty($photo))
{
$this->renderPartial('_photo', array('photo'=>$photo, true));
}
}
The "$this->renderPartial()" bit simply calls a layout file which includes a standard HTML tag to output.
Now when the user clicks on a thumbnail, the above function is called and the large image is displayed in the Lightbox.
Now if the user right clicks on the thumbnail and selects "open in new tab/window" then the image is displayed in the browser as per normal, i.e. just the image. I want to change this so that it displays the image within a layout.
In the above code I can include the following and put it in an IF statement:
$this->render('photos', array('photo'=>$photo));
This will call the layout file "photos" which contains the layout to display the image in.
I have a specific limitation for this - the image URL must remain the same, i.e. no additional GET variables in the URL. However if we can pass in a GET variable in the background then that is OK.
I will most likely need to change my function above so that it calls a different file for this functionality.
EDIT: To demonstrate exactly what I am trying to do, check out the following:
http://www.starnow.co.uk/KimberleyMarren
Go to the photos tab and hover over a thumbnail - note the URL. Click the thumbnail and it will open up in the Lightbox. Next right click on that same thumbnail and select "open in new tab/new window". You will notice that the image is now displayed in a layout. So that same URL is used for displaying the image in the Lightbox and on its own page.
The way StarNow have done this is using some crazy long JavaScript functionality, which I'm not too keen on replicating.
The html link should point to the layout showing the image on a new page by default, e.g.:
<a href="mysite/images/show/123" rel="gallery">
Before the lightbox opens, append a query string to the url in order to distinguish it from the normal link and load the layout for the lightbox. As soon as the image is loaded in the lightbox, change the link back to its original state.
$("a[rel=gallery]").fancybox({
'onStart': function (selectedArray, selectedIndex, selectedOpts) {
var el = $(selectedArray[selectedIndex]);
el.attr('href', el.attr('href') + '?mode=lightbox');
},
'onComplete': function (currentArray, currentIndex, currentOpts) {
var el = $(currentArray[currentIndex]);
el.attr('href', el.attr('href').split("?")[0]);
}
});
You will then have to process the following link in order to return the lightbox layout:
<a href="mysite/images/show/123?mode=lightbox" rel="gallery">
You should be able to modify the JavaScript function that generates the HTML with the <img /> tag to link the image to such a page. Although, if you are trying to make it so that selecting "Open image in new tab" opens a page like this, then that might be impossible (unless there is some sort of crazy cookie/session implementation to alternate between the image script just passing an image and generating a page, which I think could be possible). To assign a new href for the link to have when you click "Open link in new tab" should be quite possible by just modifying the JavaScript function.
Could you clarify what exactly you are attempting to do? Open link in new tab or open image in new tab?
Edit: It appears that the FancyBox script is changing the href of your link to point directly to the image. You would need to find where in the script it is selecting each link tag with rel="gallery" and replacing the href to point to the images; you will want it to not change the href if you want it left as "mysite/photos/view/abc123", for example.
If you need the same functionality the demo site you posted is using, then this is easy to achieve, but keep in mind that the site is NOT using the same URL for both the pop-up and the standalone image page.
Click on any thumbnail with Firebug console is open, you'll notice that it's making an Ajax request to get the image from a different URL! which is an obvious behavior.
http://www.starnow.co.uk/profile/PhotosTrackView.aspx?photo_id=2129864
While the link is pointing to:
http://www.starnow.co.uk/KimberleyMarren/photos/2129864/
you see your links should point to the correct image page, in case of JS disabled browsing or right clicking (as you mentioned) AND using JS to override the link default behavior (which is redirecting you to the image page).
So for example you can have a method that will generate your image layout/page, and this should be used as href; and override the click event of the link to call a similar method (using ajax) but this time it'll retrieve the image itself to use it in your lightbox.

Categories