-
Posts
1,078 -
Joined
-
Last visited
-
Days Won
17
Everything posted by dotnetic
-
I am using PW 2.8 so there is no namespace. Also I have the function testfunction which should just return a string but also doesn´t work.
-
I modified my module as you wrote and installed it again, but I still get the error Exception: Unknown "wireRelativeTimeStr" function in "logspot_profile.twig" at line 107
-
@Wanze @Gazley I can´t get it running. I even tried to write a module but I don´t know which class to extend. Gazley could you send me your module as a reference? Here is the code of my module: <?php class TwigFunctions{ public static function getModuleInfo() { return array( 'title' => "TwigFunctions", 'version' => "0.0.1", 'summary' => "", 'author' => "Sir Aceman", 'href' => "", 'permission' => array("page-view"), 'autoload' => true, 'singular' => true, 'permanent' => false, 'requires' => array("PHP>=5.4.0", "ProcessWire>=2.5.28", ""), ); } public function init() { $this->addHookAfter('TemplateEngineTwig::initTwig', $this, 'hookInitTwig'); } function hookInitTwig(HookEvent $event) { $twig = $event->arguments('twig'); $twigWireRelativeTimeStr = new Twig_SimpleFunction('wireRelativeTimeStr', function ($date) { return wireRelativeTimeStr($date); }); $twig->addFunction($twigWireRelativeTimeStr); $function = new Twig_SimpleFunction('testfunction', function ($string) { return 'testfunction'; }); $twig->addFunction($function); } }
-
@Gazley I tried adding a modified version of your code to my prepended _init.php. It looks like this: function hookInitTwig(HookEvent $event) { $twig = $event->arguments('twig'); $twigWireRelativeTimeStr = new Twig_SimpleFunction('wireRelativeTimeStr', function ($date) { return wireRelativeTimeStr($date); }); $twig->addFunction($twigWireRelativeTimeStr); $function = new Twig_SimpleFunction('testfunction', function($string) { return 'testfunction'; }); $twig->addFunction($function); } But when I try to use a function in a twig template like {{ wireRelativeTimeStr('1469455438') }} I still get Exception: Unknown "wireRelativeTimeStr" function in "logspot_profile.twig" at line 107 What did I do wrong?
-
@bernhard Sure. Provide me with details / login and I will have a look. We can also communicate in german if you like.
-
@Pete Back in 2013 @Nico Knoll asked for a "Mark as solved" button for the forums, so user could see which questions are still unsolved, which was a great feature for this forum. Now with the new version this button is missing. Could you please let it return?
-
Thank you @bernhard. Have to test it a little more, but first try worked fine.
-
So you found the answer yourself. Yes, you need to assign your variables to the view variable like this: $view->set('login', $login); All processwire API variables (page, input, config etc.) are available (per setting in Template Engine Twig). So you can use {{ page.title }} directly.
-
Hi Manaus, which Template Engine Module do you use? Template Engine Factory or Template Twig Replace, or something different? Please post the code of the twig file here. Please give more information about your setup (ProcessWire Version, etc). Normally you would call a function in twig with {% myFunc(params) %}
-
Hi there, I know there is a possibility to open the Front-End Editing window with one click if if change the class of the containing div from "pw-modal-dblclick" to "pw-modal-click". So how can I have a button/link that opens the frontend editor with a single click? I want to use a code similar to this: <edit field="title,user_image,facebook_url,description"> <a href="#" class="waves-effect waves-light btn pw-modal-click">edit this page</a> </edit>
-
I have an issue with the z-index of the UL with the id="notices". When I scroll it overlays the mainmenu as seen on screenshot. Z-Index should be lower. PW 3.0.25
-
@sindresorhus Truly addictive. Love it. Also wanted to recommend Kung Fury. If you like the music check out Kavinsky - Testarossa Autodrive
-
@felix pointed me to the following post which provides a possible solution for avoiding multiple session_starts, but I don´t get it to work. When I use Zend_Session::start(); I get an error Uncaught Error: Class 'Zend_Session' not found because Shopware or Zend is not included in ProcessWire. I try to include ProcessWire into Shopware.
- 2 replies
-
- shopware
- integration
-
(and 1 more)
Tagged with:
-
This seems to be answered here
-
I want to use the ProcessWire API and rendering of templates inside of a Shopware installation. So CMS pages should be served via ProcessWire (but with elements like a shopping cart coming from Shopware) and the products category page and the products detail page should be served from Shopware. How would I do that? I tried to include ProcessWire´s index.php into the shopware.php and even Shopware´s autoload.php but when I do this, I get a 500 Server Error. I use ProcessWire Version 3.0.24 (devns) and Shopware 5.2.1 My shopware directory is located at the same level as ProcessWire´s index.php and site and wire directories. Now I enabled ProcessWire´s debug mode and I get the following error: Error: Uncaught Zend_Session_Exception: session has already been started by session.auto-start or session_start() in K:\xampp\htdocs\meinprojekt\relaunch2016\src\shopware\engine\Library\Zend\Session.php:473 Stack trace: #0 K:\xampp\htdocs\meinprojekt\relaunch2016\src\shopware\engine\Shopware\Components\DependencyInjection\Bridge\Session.php(77): Zend_Session::start(Array) #1 K:\xampp\htdocs\meinprojekt\relaunch2016\src\shopware\var\cache\production_201607041559\proxies\ShopwareProductionda39a3ee5e6b4b0d3255bfef95601890afd80709ProjectContainer.php(679): Shopware\Components\DependencyInjection\Bridge\Session->factory(Object(ShopwareProductionda39a3ee5e6b4b0d3255bfef95601890afd80709ProjectContainer)) #2 K:\xampp\htdocs\meinprojekt\relaunch2016\src\shopware\vendor\symfony\dependency-injection\Container.php(314): ShopwareProductionda39a3ee5e6b4b0d3255bfef95601890afd80709ProjectContainer->getSessionService() #3 K:\xampp\htdocs\meinprojekt\relaunch2016\src\shopwar (line 473 of K:\xampp\htdocs\jentschura\p-jentschura\relaunch2016\src\shopware\engine\Library\Zend\Session.php) This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged. So it seems, when I include ProcessWire, it wants to start a new session, but Shopware already started one. Any suggestions what to do?
- 2 replies
-
- shopware
- integration
-
(and 1 more)
Tagged with:
-
“Design Better Forms” by @CoyleAndrew https://t.co/7Tz90m4zbS Everything written there is the same that I always preach.
-
Maybe you want to mark this question as answered?
-
My replace Textformatter does not work. Please help
dotnetic replied to dotnetic's topic in General Support
-
@adrian @Wanze How can I make this work with TemplateEngineFactory and Smarty? Your search function tries to render a normal template file but it does not output my search page (which I selected in module settings). So I tried to modify the search function to use a partial that would be rendered, but it didn´t work either: public function search($event) { if($this->searchPage) { $request = parse_url($_SERVER['REQUEST_URI']); $path = $request["path"]; $result = trim(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $path), '/'); $term = str_replace(array('-','_','/','%20'),' ',$result); // New way of setting the value of get->q directly. // This way, this module can work out of the box with no need to modify the search.php template file $this->input->get->q = $term; // Setting the value for $options['q'] in the render is for backwards compatibility // and as a way to identify that this module is rendering the search template so the // dev can choose to output conditional content such as if(isset($options['q'])) $content .= $pages->get(27)->body; $templateFilename = $this->pages->get($this->searchPage)->template->filename; $factory = wire("modules")->get('TemplateEngineFactory'); $partial = $factory->load('search.tpl'); $event->return = $partial->render(); } Any suggestions how I can get this to work? EDIT: It seems that the Smarty File is beeing loaded but I get much undefinded index errors. The errors appear because it seems that my _init.php isn´t prepended.
-
Found the solution by myself. Maybe this helps others. It works if you use the so called subscript syntax From the Twig docs: You can use a dot (.) to access attributes of a variable (methods or properties of a PHP object, or items of a PHP array), or the so-called "subscript" syntax ([]): So instead of using {% if page.facebook %} Just use {% if page['facebook'] %} and it works
-
I tried to use the TemplateEngineTwig in PW 3.0.22 (devns). It did not work. Then I downloaded the latest version of twig from their website and replaced the lib folder in the modules\TemplateEngineTwig folder but I still get the same error: Error: Exception: An exception has been thrown during the rendering of a template ("Method Page::homepage does not exist or is not callable in this context") in "logspot_profile.twig" at line 20. (in K:\xampp\htdocs\logspot-pw\src\site\assets\cache\FileCompiler\site\modules\TemplateEngineTwig\TemplateEngineTwig.module line 111) Here is what I try to do: {% if page.homepage %} <a href="{{ page.homepage }}" target="_blang">Homepage</a> {% endif %} Anyone got a simple solution?
-
Take a look here https://processwire.com/talk/topic/6833-module-templateenginefactory/?p=78641 and also my comment https://processwire.com/talk/topic/6833-module-templateenginefactory/?p=122354