Have problems with using Volt with phalcon
By : George Waldon
Date : March 29 2020, 07:55 AM
wish helps you That comes from the fact that the application cannot find the file main.html in the actual path. If you add the full path it works, however it is inconvenient to do so. Something like this will work code :
{% extends "../views/layouts/main.html" %}
{% extends "../app/views/layouts/main.html" %}
|
How can I set own Tag class in Volt (Phalcon)
By : Royalpharmacy
Date : March 29 2020, 07:55 AM
I wish did fix the issue. First of all: don't use tag as your service name because it's already used by Phalcon's Tag object. Secondly you can use static methods from class. Below is a working example for myTag using config from my app with changed names for your example. code :
$di->set(
'view',
function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(
array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(
array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_',
'compileAlways' => false
)
);
$compiler = $volt->getCompiler();
// add a function
$compiler->addFunction(
'myTag',
function ($resolvedArgs, $exprArgs) {
return 'MyTags::mytag(' . $resolvedArgs . ')';
}
);
// or filter
$compiler->addFilter(
'myFilter',
function ($resolvedArgs, $exprArgs) {
return 'MyTags::mytag(' . $resolvedArgs . ')';
}
);
return $volt;
}
)
);
return $view;
},
true
);
class MyTags extends \Phalcon\Tag
{
/**
* Look no static keyword here
*/
public function mytag($params)
{
<...>
}
}
$di->set('mahTag', function() {
return new MyTags();
};
{{ mahTag.mytag() }}
|
Phalcon count in volt
By : Paul Frol
Date : March 29 2020, 07:55 AM
may help you . I have a counting problem in phalcon volt. I have a table named category and there I have two columns id and cname, and also have a table blog and there is a column category. I want to show how many post have in each category. , No Sir, its not working. But i just solved my problem like this : code :
[controller]
$categories = Category::find();
$this->view->setVar('category', $categories);
[volt]
{% for categories in category %}
<a href="blog/category/{{categories.cname}}" class="tags">{{ categories.cname }}
<span>[
<?php
$catcount = $this->modelsManager->executeQuery("SELECT Blogs.category FROM Blogs WHERE Blogs.category = $categories->id");echo(count($catcount));
?>
]</span></a>
{% endfor %}
|
Hyperlink does not work on volt in phalcon
By : Daniel Farias
Date : March 29 2020, 07:55 AM
it fixes the issue i have a menu in my volt which is by default hidden by css, and its shows by jquery slide. its every links are getting its url but when i click its not go to that page. its work when i call its url by jquery. im not understanding whats the problem is? , Your links are not working because of: code :
$(".menu").click(function(e){
e.preventDefault();
$(".logform").slideToggle(400);
return false;
});
$(".m").click(function(e){
e.preventDefault();
$(".d").slideToggle(500);
return false;
});
|
How to foreach form to volt in Phalcon?
By : Mimiz
Date : March 29 2020, 07:55 AM
|