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>
Related
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
I have a self-made math captcha and it should be output without anything before it's image header, so I can't make it a 'View'. I put this captcha.php in the web root dir, but it can't share session with scripts in Yii. How to solve this?
Is there any way to pass the session from Yii to the other scripts or clean anything before the header in view?
Though it is true that the default layout wraps the page's content with the typical html markup you'd expect, you have complete control over that by specifying the layout you'd like from the controller by using $this->layout = ... You can set it to null to use module layout or false to disable the layout completely. See more details in Yii API Docs.
Alternatively you can call $this->renderPartial('view name') if you'd like the output of your captcha script displayed without the surrounding page content.
Currently working with ZF and ZendX_JQuery.
As I understand, script links to Google's CDN JQuery are only included in the <head> section of a view if ZF JQuery is referenced in some way in the MVC.
However, I'm working with 'Cloud Zoom', a JQuery library for image zooming.
The view I wish to include Cloud Zoom in has no reference to JQuery, and therefore the script links are not included in the head. How can I make ZF include the script links in the head section of the page without explicitly including any ZF JQuery references in the MVC?
from http://framework.zend.com/manual/en/zendx.jquery.view.html
To access the javascript we have to
utilize the jQuery() functionality.
Both helpers already activated their
dependencies that is they have called
jQuery()->enable() and
jQuery()->uiEnable()
i have this code in my layout
if ($this->jQuery()->isEnabled()) {
$this->headScript()->appendFile('/scripts/jquery.ui.datepicker-it.js');//localizazione di DatePicker
echo $this->jQuery()->setRenderMode(ZendX_JQuery::RENDER_JAVASCRIPT | ZendX_JQuery::RENDER_JQUERY_ON_LOAD);
}
so i guess you have to do something like $this->jQuery()->enable()->enableui()
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>
I am new to Code Igniter and I wish to know if there is anything that works like MasterPages do on .NET.
Also i was wondering where should i keep my public files, like scripts, styles and images.
Greetings, and Thank you in Advance
Master views aren't built into the framework. To get a similar effect you can load the subview and pass that to the master view.
Controller :
class Items extends Controller
{
function show($id)
{
$item = $this->item_model->get_item($id);
// Load the subview
$content = $this->load->view('item/show', array('item' => $item), true);
// Pass to the master view
$this->load->view('master_view', array('content' => $content));
}
}
Master view :
<div id="header">
</div>
<div id="content">
<?php echo $content; ?>
</div>
<div id="footer">
</div>
To answer your other question, I keep all Javascript scripts and CSS in directories in the root of my project.
I'm not sure that they have anything exactly like a master page. CodeIgniter is more of an MVC framework and uses views and controls to build up pages. If you're new to CodeIgniter, net.TutsPlus has a real good series of videos that goes into some depth about how to use the framework for different scenerios. Take a look under the section called "Catch Up" to see the list of videos.
Hope this helps out some and good luck in your project.
try this library
http://www.williamsconcepts.com/ci/codeigniter/libraries/template/?v141
I am not too familiar with .NET or CodeIgniter, but it appears the same functionality can be provided by judicious use of Views. The first sentence on that page says:
In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type of hierarchy.
This seems like exactly what a MasterPage provides. And in fact, most PHP frameworks and templating systems provide the same features.
In answer to your second question, you may want to keep your scripts, styles, and images in separate folders off of the web root. I believe that URLs are relative to index.php, so keeping your resources near there would make them easier to refer to in your views. Another option is to take a look at the Asset Helper.