CSS file in same view/scripts folder as phtml file - zend-framework

I have a CSS file that is in the same view/scripts folder as the phtml file that will use it. What is the correct parameter for $this->headLink()->appendStylesheet() for such a file?

Your css file must be accessible in public directory or public subdirectory like public/css/your_css_file.css
In your view, you can do something like this:
$this->headLink()->appendStylesheet($this->baseUrl() .'/css/your_css_file.css');

Normally your CSS file should be accessible publicly (within the public folder).
However, if you still want to leave it there (you will have performance issues especially if your file is large) just do so within your view file
<?php
$this->headStyle()->captureStart();
echo $this->partial('css-file.css');
$this->headStyle()->captureEnd();
?>
This will allow your file contents to be output, captured and then "injected" in the appropriate place in the layout.
Hope it helps

Related

Magento 2 : Is it possible to switch extension from html to phtml

I have an html file and in this file I would like to call some block method
app/design/frontend/Theme/default/Magento_Checkout/web/template/billing-addresses/form.html
So I would like to add something like that :
<?php $store = $block->getStoreCode(); ?>
But the file being an html I can't do that.
My question is : Can I just change the form.html into a form.phtml without breaking anything ?
If I can't, how can I get the value I need ?
Thanks.
No you cant.
.Html files are used for the knockout components, their logic is in the .js files and their data comes from the php files.
.Phtml files for the blocks
If you want to add some extra logic to the html file - check out documentation and other sources about js components.

Matching of data files to pages

I have used the assemble/boilerplate-site as a test bed. Following the examples on http://assemble.io/docs/Data.html I have created a page named test.hbs and a data file named test.yml.
The yaml file contains:
title: stuff
when running grunt assemble, a test.html page is assembled into the destination directory. if my test.hbs contains the tag {{title}} the title is not added from the data file, however a tag of {{test.title}} does add the title from the data file.
on the docs page http://assemble.io/docs/options-data.html it states:
When using "external" data files (versus YAML front matter), if name of the data file is the same as the associated template then Assemble will automatically associate the two files.
I also need to use the {{title}} tag in my layout. This works if I use YFM at the top of the page rather than an external data file.
Am I misunderstanding how external data files are associated with a page or am I missing something?
You can use {{page.title}} in your test.hbs and layout.hbs files to access the variable without having to specify the actual page name.

Does the testandtarget.js file have a purpose?

While analyzing some requests on our dispatcher, we noticed that we continually get a 0 byte file generated from hitting the following path
/etc/clientlibs/foundation/testandtarget
This file is a ClientLibraryFolder. Its js.txt defines the base file as such:
#base=source
There is no "source" folder that is a direct child of testandtarget. The testandtarget folder contains two ClientLibraryFolders, mbox and util. The js in these folders is loaded on the page just fine. This is why Test&Target still works. However, the testandtarget ClientLib seems to be wrong by default (this is the OOB 5.5 setup). We get a 0 byte file because the js.txt file's base points to a folder that does not exist.
Is anyone else seeing the behavior? It appears that I could just rewrite the js.txt file. Are there any ramifications for doing so?
As best I can tell, that node is an empty clientlib, but it has a child node of "mbox" with the same clientlibrary category. That clientlibrary WILL produce content, and references a source folder beneath it.
http://{localhost}/libs/cq/ui/content/dumplibs.test.html?categories=testandtarget
http://{localhost}/libs/cq/ui/content/dumplibs.html?categories=testandtarget&type=JS&theme=
I am not aware of the version history, and whether it used to have valid content, or is planned to in the future.
I would be more tempted to remove or change the category than to play with the js.txt file. Editing the js.txt file will change what content goes into the clientlib. Changing/removing the category would no longer cause a call out to the zero byte file.
<cq:includeClientLib categories="testandtarget" />
=>
<script type="text/javascript" src="/etc/clientlibs/foundation/testandtarget/mbox.js">
<script type="text/javascript" src="/etc/clientlibs/foundation/testandtarget.js">

How to dynamically change the content of HTML in eclipse

I am getting the path of HTML file from IFile-
The method is like -
public IStatus runCustomizer(final IFile file, final IDOMPosition position)
{}
Through this IFile, I am getting an HTML file. Now I want to modify the html file.
I'm not sure the question is restricted with Eclipse. You can read file into any DOM presentation e.g. JDom, Saxon, Xerces etc. and perform XSLT transformation on it. This way is most common but heavy. You can perform customization on DOM presentation manually. These ways are acceptable only if your html file is well-formed. If no you can work with it like with text file but this is more error prone approach.

how to refer one .phtml in the other views in Zend

am new in Zend framework.
I have one .phtml file, includes menus section. i need to add that .phtml file in to the views i.e views/scripts/index.phtml page.
how can refer that
please advice
thanks in advance
You can use the render helper:
<?=$this->render('menu.phtml')?>
If you want to pass specific variables to the rendered script, use the partial helper:
<?=$this->partial('menu.phtml', array("varname" => "value"))?>
The menu.phtml file must be in the search path, which usually is the path to the current module's scripts directory ( view/scripts ). You can either place the menu.phtml file in this directory, or add a directory to the search path using the addScriptPath() method on the view object.
Try this
echo $this->partial('path/file.phtml', 'ModuleName')