Render view script inside iframe in zend framework - php

I want the view script of one of my controller actions to be rendered inside an iframe in my zend framework application. how it is possible?

Have a separate action (maybe controller too ...) for the view you want to render inside the iframe ( you'll probably want to play in this action with $this->_helper->layout()->disableLayout(); or maybe change the layout ... depends on what you're trying to achieve ) , then in you're view you want to show the iframe do
<iframe src="you're iframe action uri">
<p>Your browser does not support iframes.</p>
</iframe>

same as it is in the browser,
set the iframe src to /controllers/view/,
Think if an iframe as a browser in the page with advanced JS controls.

Set the proper Doctype supporting iframes
Then,
In your view:
<iframe src="<?= $this->url(array(
'module'=>'yourmodule',
'controller'=>'yourcontroller',
'action'=>'youraction'),
'default', true); ?> ">
<?= $this->render('/path/to/your/view/youraction.phtml'); ?>
</iframe>

Related

Wordpress functions are not working inside iframe in wordpress

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/

Including External CSS in Laravel 4 without Blade?

I'm building a login page that is just h1, two input fields, and a submit button. I really don't need a template for this. Is there a way to include the external css since I can't use {{HTML::whatever}} to include CSS?
You can use laravel url helpers.
http://laravel.com/docs/helpers#urls
Also you can user HTML::whatever() within php tags.
<?php
echo HTML::style('assets/stylesheet/main.css');
?>
You can still do it in traditional HTML style inside the view, either with style tags or attaching to an external stylesheet.

F3 Framework Template serve not calling PHP functions

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

Load Child Views into IFrame with Zend Framework Application

I have a client-side html and javascript application that uses a REST API, that returns JSON. Right now I have the main page when you login, store profile information in a javascript object. Then all other pages in the system are displayed in an iFrame, so that they can access the JSON data in the parent page, without making another ajax call.
I need to move the appliation to Zend Framework, due to future requirements, and I'm not sure how to render a single view, that contains an iframe, and then load all other views into it, instead of instantiating a new layout template and just loading the view.
I know enough about Zend Framework to get started, so I'm not looking for basic Zend Framework help, just a crazy use case, why an iframe...I don't know, client requirements.
Thanks in advance :)
Set your default layout to be the one used in iframes (ie, minimal decoration)
; application.ini
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "iframe"
; refers to application/layouts/scripts/iframe.phtml
In your main page controller, set the layout to be the full page version
public function indexAction() {
$this->_helper->layout->setLayout('full');
// refers to application/layouts/scripts/full.phtml
}
In your full page layout, create your iframe and name it
<iframe src="" name="content" height="100" width="200">You need a Frames Capable browser to view this content.</iframe>
In your main page view, direct links to open in the iframe
<a href="<?php echo $this->url(array(
'action' => 'some-action'
)) ?>" target="content">Click me</a>

How to get Kohana base_url in template

In Kohana 3 bootstrap.php one can define base_url:
Kohana::init(array(
'base_url' => '/foo/',
));
This usually means also moving the /js/, /css/ and other media to that base dir like /foo/js/, /foo/css/. My question is not to discuss good or bad of such.
Is there a built-in way in Kohana to access the base_url from a template (just like in Django you can use {{ MEDIA_URL }}css/)?
You can output the base url as using URL::base:
<?php echo URL::base(); ?>
If you're outputting a url relative to that you probably want URL::site:
<?php echo URL::site('css/'); ?>
Kohana 3 template controllers use the View class to render templates.
Views are normal php files and have no special syntax, so just use the normal <?php ... ?> tags as above.
The View class allows you to declare variables for use in that view, before you render it.
One good way is that in your layout view, in the head of the HTML you put near the <title> tag:
<base href="<?php echo URL::base(TRUE) ?>">
and then, you load your assets this way:
<img src="assets/images/img.jpg" alt="">
The HTML <base> tag is a way of defining a base URL for all the assets in the page. This way you load your image located at /foo/assets/images/img.jpg without making a URL::base() call in every tag. I hope it helps.

Categories