How to show the tab in phalcon - tabs

I have set of code of tutorial INVO as pre the Phanlcon Official documentation.
I just want to customize the code as per my need, So I wrote some code to prepare a fresh Module.
I created the below files that are needed to create the full module
app/controllers/AbcController.php
app/model/Abc.php
app/forms/AbcForm.php
app/view/index.volt
app/view/edit.volt
app/view/search.volt
app/view/new.volt
After creating all these file, I am able to runt he module,but In this particular module I am not able to see the tabs having the links.
I think I am missing something, Help me out.

I face the same problem recently, and even the solution is not there in the official documentation of Phalcon.
I came with the solution take reference from another module. There is one file missing in your Code structure that is layout file.
For any module you need to define a layout at least. You have to create a file as below.
app/view/layouts/abc.volt
In this you have to put the code according to your need that where you want to show the content where center or left align.
{{ elements.getTabs() }}
<div align="center">
{{ content() }}
</div>
Here {{ elements.getTabs() }} is used to show the tab. Hope you will get the solution.

I also came with the updated answer.
There could be different layout for any view. You just need to define the layout same as the class name. That's It. !
app/view/layouts/test.volt
or
app/view/layouts/test.html

Related

How can I use macros/variables/scripts in articles with Pelican?

I have just started with Pelican. It's awesome, I just can't figure out how to use macros in my articles (and pages). I know I can use Jinja when making my own theme, but I can't seem to be able to use it in articles. I'd like to be able to define a macro/function/template/whatever that I'd put directly in the markdown of the article, possibly with parameters, and it would get expanded when the pages are generated. For example a function to generate an image with a caption of given size and css class that would also be a link directly to the image. I'd like to be able to access these macros from all articles, to be able to reuse them everywhere. Something I'd normally do with PhP.
I could probably use JS to do this, but if I'd like to avoid it and keep everything static if possible. Can this be done?
UPDATE:
I found a pelican plugin that solves this - jinja2content.
OLD SOLUTION:
I found a solution here. You can implement a filter in Python to process all texts in articles/pages like this:
Create a python file filters.py in which you write the filter function process_text to expand my macros (or generally do anything with the article/page text), for example to test the function write something like:
def process_text(input_text):
return "TEST " + input_text
In the Pelican config file (pelicanconfig.py) register this function as a possible filter to be used with Jinja:
import sys
sys.path.append('.')
import filters
JINJA_FILTERS = {'process_text':filters.process_text}
Now you have to edit the templates to apply this filter to article/page texts before adding them to output. In my case I edited two files: themes/themename/templates/article.html and themes/themename/templates/post.html and changed {{ article.content }} to {{ article.content|process_text }} and {{ page.content }} to {{ page.content|process_text }} in them to apply the filter.
Now all texts in articles and pages should be prefixed with "TEST".
The not so convenient thing about this is I have to write my own macro expander, which shouldn't be extremely hard with regular expression in Python, but if there is a nicer way to do this, feel free to post here.

A method of including one HTML file in another which I do not understand

I've come across an HTML file which includes this snippet:
<div class="Header" role="banner">
{% include 'header.html' %}
</div>
I realise the purpose is to include the file 'header.html', but I've not come across this syntax before. Can someone explain it to me, please.
The site where I found it is:here
I have been encountering this using symfony[PHP framework].
And as what I had understand from our class last semester, that the include() statement tells the Web server to go and get the header.html and include it in the page.
I have a link pasted down here. Hope it can help :)
http://www.apaddedcell.com/how-automatically-include-your-header-navigation-and-footer-every-page
Maybe it is a twig template:
http://twig.sensiolabs.org/doc/tags/include.html
The syntax would fit!
That looks very much like Django, a template language for Python - and it would very much do the same as a PHP include, which is to include the content from another template in the code.

FancyTree: Adding a custom icon by HTML?

I am using HTML to do the basic FancyTree initialization of a folder tree control and I was wondering if I could also specify a custom icon for these folders, i.e.,
<li id="xyz' class="folder" data-icon="myFolderIcon.gif">Folder Name
In the definition of my FancyTree control, I specify an imagePath:
$("#tree").fancytree({imagePath: "skin-win8/",
but all I see is an empty spot where my icon should appear, even though I placed my custom icon in the skin-win8 folder. What's the simplest way to add a custom icon or two to a FancyTree control? I'm both a FancyTree and CSS neophyte, in case you were wondering :)
Sheldon
That looks ok to me. Basically the same as in this demo:
http://wwwendt.de/tech/fancytree/demo/sample-theming.html
Maybe simply a typo in your markup:
<li id="xyz' class="folder" data-icon="myFolderIcon.gif">Folder Name
(should be id="xyz" instead of id="xyz')
Thanks again to mar10 to pointing me in the right direction, even though his thought that I had a typo in my markup was not the actual culprit. But by saying that he didn't see anything wrong and referring me back to his demo for custom node icons, it got me thinking that perhaps I too was also experiencing an imagePath issue, like this previous custom-node question
So I went back to my FancyTree download and got the custom-node example working on my server, then I moved the page and its dependencies around till I got something similar to my situation. Once I had that working, I was able to use the same approach within my actual page...
I happen to keep all my FancyTree-related files in a directory called fancytree within my application's web folder, so I added a subfolder called custom there and set my imagepath in the following manner:
imagePath: "fancytree/custom/",
Once I did that, I was able to use my custom icon either by including it in the HTML definition of the node or by setting it within the Javascript function I used to initialize certain aspects of my tree. Hope this helps some other custom-node newcomer...
Sheldon

django + mysql text field format with breakline

I have a text field in my MySQL table. I want to format all new lines with the <br> or some sort of formatting for the template. Is there anything built into the framework for this? I tried to read into the following page:
https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs
But seems like that page won't work for this? Is there another documentation I can refer to? Thanks!
It sounds like you need the linebreaksbr template filter.
Normally, you would use it in the template:
{{ instance.fieldname|linebreaksbr }}
However, it's possible to import it and use it in your view as well:
from django.template.defaultfilters import linebreaksbr
text_with_br = linebreaksbr(instance.fieldname)
The advantage of using linebreaksbr instead of writing your own snippet, is that the linebreaksbr takes care of autoescaping for you.
I decided to do it the following way: "<br />".join(word.split("\n")). Not sure if that's the best way...still digging into it. It certainly works though!
It may be overkill for you depending on your use case, but I use django-tinymce in my admin area to add rich text editing fields to charfields that will be used in templates. This saves a html string in the database and in your template you can just use:
{{ model.field|safe }}
to output it without losing the html formatting. It's quite easy to set up.

Mediawiki 1.16: Template documentation example usage

I'm writing template documentation for a wiki and wanted to include a working example of the template. However, I wrote the template to auto-categorize various fields and the entire template itself is also auto-categorized.
This means if I simply call on the template, it will categorize the doc page...and because the actual template page transcludes the doc page, the template page will also be categorized.
Is there a way to prevent these categories from automatically kicking in?
Something like the following should do the trick. Wrap the categorization in your template inside a parserfunction:
{{#ifeq: {{NAMESPACE}} | Help || [[Category:Some_Category]] }}
This sets the category when the template is transcluded onto a page that is not in the "Help" namespace.
Another option is to allow a parameter such as demo to avoid including the category.
If you don't mind being slightly cryptic, you could do the category in the template as {{{cat|[[Category:Some_Category]]}}}; then specifying the parameter as {{my template|cat=}} will prevent the category inclusion.
I'm not sure if I understand the question completely (what is "auto-categorize various fields"?). I am assuming here that you want to show a template "in action" on a documentation page - without attaching some categories (those categories the documentation page usually attaches to articles using this template) to the documentation page.
So
<onlyinclude>[[Category:Some_Category]]</onlyinclude>
will not do the job - as the template is in fact included. Right?
Try passing a parameter categorize=false to the template to indicate that categories are not to be attached in this case:
{{#ifeq:{{{categorize|}}}|false||[[Category:Some_Category]]}}
The double pipe after "false" means: if(categorize==false) then (empty), else [[Category:Some_Category]] - i.e. it is an equivalent construction for if(NOT(categorize==false))...
Good luck and thanks for all the fish,
Achim