I am using an iframe in wordpress, but the page inside iframe not supporting wordpress functions.
the page inside iframe is from the same domain.
Here is what i am trying to do:
I am trying to call a css inside iframe page via wordpress function. Below is how i am using iframe tag :
<iframe id="iframeBox" src="<?php echo get_template_directory_uri();?>/iframe/scoreboard_summary.php" sandbox="" FRAMEBORDER="no" ></iframe>
Here is the css calling tag in my page scoreboard_summary.php :
<link type="text/css" rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style.css">
the function get_template_directory_uri() is not working ?
Please let me know what should i need to do?
Thanks in advance.
iframes are just webpages pulled in and shown in a div. You can't interact with them in that way. PHP has already spit out what was defined by the loops and rules you set. You would want to look into ajax for something like that if you want to talk to the server and bring up new data at an interval, and skip the iframe.
<?php echo 'do this thing' ?> just turns into this thing after the page is loaded. There isn't much to hook into.
If you are just trying to get the stylesheet and apply it to you your page, then I would suggest getting the whole, standard, URL for that stylesheet and skip the template directory uri etc.
Maybe you can explain it better with some code or an example like this one, it's an iframe that refreshes at an interval. Good Luck!
http://jsfiddle.net/sheriffderek/3C9qP/
Related
I'm trying to set up a development server used by designers to test CSS before a deployment. The caveat is I want to be able to load HTML / PHP into an iframe, but have a variable passed to it that will allow me to swap the link to CSS from within the iframe. This will emulate the control I have over the production ad feeds that come via iframes.
I attempted a function that returned HTML with a variable css link, but it will not come back as an iframe, of course. The iframe will ensure the included css is the only css that will be used, and that the main page css will not affect the content of the iframe.
How can I load an iframe with a variable CSS link?
The solution is to use an iframe with a query string parameter on the source.
<iframe height="100%" width="100%" frameborder="0" src="/inc/mockads.php?css=<?=($settings['stylesheet']);?>">
which will pass the pre-defined stylesheet to the markup to be iframed. Then, in the mockads.php file, I add the logic to do:
<?php
if ( isset($_GET['css']) && strlen($_GET['css']) )
{
$stylesheet = $_GET['css'];
}
?>
Then the rest of the markup, with the link set like
<link rel="stylesheet" href="<?=$stylesheet;?>" type="text/css" media="all">
I'm trying to build a custom top toolbar which an iframe below it.
Something similar to this:
http://themes.goodlayers.com/?theme=greenearth
I plan one using it on a blog, so i will be making posts linking to other sites. My question is what do i need to make a custom url function that so i just add it in front of the other site's url so that it shows up in an iframe.
For example:
I want to link to google in an iframe with my top toolbar above.
Is there a script that allows me to use a url like this:
http://www.mywebsite.com/frame.php?http://www.google.com/
Thanks for your time!
Iframes are always bad. Don't do it.
That said, with PHP, you can do this:
<iframe src="<? echo $_SERVER['QUERY_STRING'] ?>" />
You can also do something like mywebsite.com?url=google.com, and use $_GET['url'] instead.
Eg url: http://mywebsite.com/index.php?iframe=http://www.google.ro
PHP:
<?php
if ($_GET['iframe']) {
echo"<iframe src='".$_GET['iframe']"' width='200px' height='150px'>";
} ?>
I hope this will help you!
It seems F3 framework doesn't handle php function calls within a page? I have a php navigation bar, which is uniform site-wide. I call up my layout page in my controller class thus: Template::serve('layout.php'). In the layout page, I include the navigation bar thus: <F3:include href="navbar.php" />. Within the navbar (navigation) file, I call a utility function siteUrl which gets the absolute url to a resource e.g. css or .js file. This function is defined in an include file which I include as follows: require_once "lib/globals.php. Within the navbar.php, I use the siteUrl as follows for example:
<img id="logo" alt="logo" src="<?php echo siteUrl('small-logo.png') ?>" />
This doesn't seem to work. When I view the generated source of the page, the src section of the img tag is an empty string: "". However, when I call the navigation bar from other pages that are not using the F3 framework (i.e. pages that are not being routed by F3::route. Not all pages of the website are routed using F3), it works fine.
What could be the problem? How could I call a php function from within a php page that is being rendered using Template::serve? It seems the entire content between the <?php ?> tag is not being executed when the page is being served by F3. Echo statements are not being displayed. Thanks for responses.
Template::serve() does not allow PHP. It is a templating engine. There are things you can do. You can define a function using F3::set('sum',function($a,$b){return 1+2;}); and then reference that function in the template with {{#sum(1,2)}}. I would re-read the templating documentation on the fatfree site: http://bcosca.github.com/fatfree/#views-templates
Again, the reason PHP is not working is because you are using Template::serve() and are therefore using the templating features of Fatfree. If you want to use PHP, I believe you can use F3::render() instead and it will render the page, allowing PHP, but you will lose all the templating functionality.
you can use raw php within the template tokens wrapped by curly brakets like this:
<img id="logo" alt="logo" src="{{ siteUrl('small-logo.png') }}" />
it will echo it automatically.
but using F3::set('image.smallLogo',siteUrl('small-logo.png')) to define the image paths and grap them with a simple {{#image.smallLogo}} feels much better.
page moved:
Fat-Free Framework 3 Template Directives
In my new website I have a logo that when clicked should return visitors to the home page. But instead it returns the 404 error page. The code for this in header.php is this:
<div id="branding">
<img src="<?php bloginfo('template_directory'); ?>/images/brandlogo.svg" alt="Luchtspin">
</div>
Why is this happening? In footer.php I use exactly the same link and there I experience no troubles:
all content © <?php echo date("Y"); ?> <?php bloginfo( 'name' ); ?>
Background info: the original theme used is Rostar (http://wpdemo.dannci.com/preview/customfields?wptheme=Rostar). I redesigned it, made it translatable and eventually married it to the Boilerplate/Starkers theme (http://wordpress.org/extend/themes/boilerplate). Adventurous, I know. Especially since I am new to PHP.
Additional info: the wordpress-site is located in a subdirectory. I followed the steps indicated here: codex.wordpress.org/Giving_WordPress_Its_Own_Directory to set it up correctly.
Link to the site: http://www.luchtspin.nl
Something strange I noticed at the same time: the h1 'Luchtspin' (next to the logo) acts like a link, although it is not a link anymore (it was a clickable div before). It returns the same 404 page. I have several caching plugins installed, but all are deactivated long ago.
Any help greatly appreciated, I've been at this for days now.
The problem seems to be on the selector you have used on line 18 of script.js. you were selecting div#branding which has an undefined .href property. Changing the selector to something like #branding a should resolve the error.
One of the JavaScripts is acting up. It appends the word 'undefined' at the back of your URL. Is there any JavaScript that you use that might alter the URL?
KahWee Teng is right, chechk your javascript ( probbly the one that is reponsible for thebrandlogo.svg spin ). It tries to overwrite your url, but, since it has no value, it just prints out "undefined".
The bottom works because it is a plain link.
Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.
You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>
The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>
Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed