I need to add the main navigation/header from my Zend based site onto the top of a third party product. The third party product will allow me to include any file(s) on the server into their layouts. My thought was I would run a cron that would save the header part of my Zend layout to a hard coded html file each night. Then just read in the appropriate file on the third part.
So I tried:
$htmlcontent = $this->view->render('file.phtml');
then saving $htmlcontent to a file. It saves out everything from file.phtml correctly but excludes the layout/header, which the part I really need. How would I go about saving everything generated ( including layout) to a file.
thanks
summer
The view script is just a part of the whole layout. In a normal Zend Framework setup, you will have one layout in which your view scripts (eg, file.phtml) in your case. The layout file will look like this:
<html>
<body>
<div>My header here</div>
<?php echo $this->layout()->content; ?>
<div>I have a footer here.</div>
</body>
</html>
$this->layout()->content will hold your view script, according to the page you are in (eg, file.phtml when your call fileAction()).
So, to access the full HTML of your page, you have two options:
Use the good old file_get_contents and get the complete rendered HTML to a string with http request.
$htmlcontent = file_get_contents('http://yourdomain/index/file');
Get the layout instance of the Zend Framework, assign content to it, and render it to a string as follows:
$layout = $this->_helper->layout->getLayoutInstance();
$layout->content = $this->view->render('file.phtml');
$htmlcontent = $layout->render();
Related
We have a tabbox whose tabpanels use include to include content:
<tabpanels height="100%">
<tabpanel>
<include src="#load(vm.myTabUrl)" />
</tabpanel>
...
</tabpanels>
Once in a while in production, the content of the include is not displayed. This behavior seems to be random and we don't know how to replicate it.
When it happens, the generated html contains a <div> for the include which only contains another empty <div> with class z-tmp:
ZK doesn't show any errors while rendering and neither does the javascript console. Also there are no failed http (zkau) requests. Any ideas?
ZK Client Engine is responsible for conversion of ZUL to HTML at client side.
ZK has a huge in-built component support compared to HTML. But the things that are displayed on Client side will be HTML itself.
We design a page in ZUL and it is converted into HTML in action. ZUL Components are larger than HTML components in number but in the end we get HTML components only with some changes in their structure.
How the ZUL page reconstructed to HTML page ?
ZUL page are converted to Div, input, anchor mostly.
ex: Groupbox
(ZUL) --> Multiple Div (HTML)
The ID of the DOM components are dynamically generated after conversion like z_p5,z_g3 and the ID
i.e given in ZUL page can be added at AID of the Component.
The DOM component can be allowed to have multiple styles separated
by spaces.
The Widget name is added to the component style as z-widget along
with our regular styles mentioned in ZUL page. The ZK Component name is added as z-widget in the style attribute of generated HTML DOM Component. As you have already seen that z-include is added in the style attribute of Div element in the above screenshot after generation
of page.
Coming to the Actual problem,
Open the AfterCompose method of the ViewModel of this page.
Assign myTabUrl directly with another ZUL page path and Notify it with
postNotifyChange method from below.
BindUtils.postNotifyChange(null, null, ClassName.this, "myTabUrl");
May be Variable is not properly assigned or Notifying the variable may be missed which caused this problem. If possible post the ZUL and VM code here if problem still not resolved after this trial.
I would like to ask how I can block richText from changing html text under source view.
I'm using Blossom module and defined richText as #Chris J advised me to do:
Add source button to Magnolia CMS richText control
Whenever I put html code in source code, switch to normal view and get back to source view the code is changed. For example the following part of code is missing :
<div class="components"> <div class="product col img-slider"> <div id="product-image" class="royalSlider productImage rsDefault"> <div class="rsContent"> <div class="rsTmb"><img src="/magnoliaPublic/resources/XXX/products/product_7.jpg" alt="">
and is replaced with folowing
<p><img alt="" src="/magnoliaPublic/resources/XXX/products/product_7.jpg" /></p>
I need to provide the possibility for the user to put html code and next to see in on the web page.
Regards
Jan
Jan. I'd ask why you are using a rich text area if you are entering HTML. It is not really designed for this usage. Would you be better off with an ordinary text field? In the STK (you mentioned this in your previous question) you will find a component that serves exactly this purpose.
Under "Configuration" you will find it at /modules/standard-templating-kit/templates/components/content/stkHTML
You will see that the template script is simply:
[#if content.editHTML?has_content]
${cmsfn.decode(content).editHTML}
[/#if]
If you want to stick with a purely Blossom approach, you may need to recreate this but it is an incredibly simple component.
Incidentally, in Magnolia 5.4 there is a code editing field used in a similar component that offers syntax highlighting. You can see this by logging into the demo site and trying to add an HTML component to the main area of the page travel/contact.
I'm trying to set/add a class name to a div by targeting its ID but I'm not having much success at the minute.
I basically have my website navigation saved to an external file so all I need to do is make changes to one file to update all pages, but doing this restricts my website users from being able to easily identify which page of the site they are on.
I have a class="current" option that visually tells the user where they are in the menu but I can't for the life of me add the class to the navigation menu. I'm trying to run the code after the nav menu file is loaded in using the following code, where am I going wrong?
<?php include_once ("includes/page_top.php"); ?>
<script type="text/javascript">
document.getElementById('home').className("current");
</script>
className isn't a function.
Instead of this:
document.getElementById('home').className("current");
You want this:
document.getElementById('home').className = "current";
My layouts are placed inside layout/scripts/layout.phtml
i have placed the below code inside my head section of layout.phtml
<?php
print $this->headScript()->appendFile($this->baseUrl().'/js/jquery-1.7.2.min.js')
->appendFile($this->baseUrl().'/js/simpla.jquery.configuration.js');
?>
Now I want to append another javascript file from a view. For that I wrote the following code:
$this->headScript()->appendFile($this->baseUrl().'js/fancybox/jquery.fancybox-1.3.4.pack.js');
Although this appended the file but it appears before my jquery-1.7.2.min.js. What i want is that i want to add jquery.fancybox-1.3.4.pack.js below my jquery-1.7.2.min.js
How can i do this?
Your view script is rendered before the layout so the calls to appendFile() in your layout result in those scripts (jquery-1.7.2 and simpla.jquery) being appended after the one you appended in the view script.
To fix this, use prependFile() in your layout at least for the main jQuery script.
Your layout might look like this:
<?php
print $this->headScript()
->appendFile($this->baseUrl().'/js/simpla.jquery.configuration.js')
->prependFile($this->baseUrl().'/js/jquery-1.7.2.min.js');
No need to change the view script, that is fine as is.
See HeadScript Helper Example #23 which talks a bit about ordering of the scripts.
The important thing to remember that they don't mention is that your view script gets rendered before the layout does.
I've tried using a Dojo button view helper, but it appears that Zend will not automatically generate a dojo.require('dijit.form.Button'). Is this correct behavior?
Here's excerpt from my layout script:
<head>
<?= $this->dojo()->setDjConfigOption('usePlainJson',true)->addStylesheetModule('dijit.themes.claro')->setLocalPath("/js/dojo/dojo.js"); ?>
</head>
...
<?= $this->button('test', 'test') ?>
And this is in my bootstrap:
public function _initDojo() {
$view = $this->getResource('view');
$view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
Zend_Dojo::enableView($view);
Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
}
All other Dojo-specific code is rendered properly, except the dojo.require.
I've not used the dijit helpers on their own so I only have a partial answer for you.
ZF definitely automatically adds the appropriate requires when you use dijit elements in Zend_Dojo_Form. From looking at the helper code it looks like this should happen when you use them on their own as well.
If you are really calling $this->button in your layout as in your example, then I would guess that it's not working simply because the dojo helper has already run by the time your helper is called. You could try moving the same call to a view script instead to see if this solves the problem (view scripts are rendered before layouts).