-
Posts
1,070 -
Joined
-
Last visited
-
Days Won
16
Everything posted by dotnetic
-
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
-
Hi Wanze, EDIT: Found the solution by myself. Added to the bottom. I got a problem with Search and the TemplateEngineFactory (I use Smarty). If I use AJAX my search.php should return a JSON response (with correct headers), if not it should render the template. The problem is that if I have a template file search.tpl it will always be rendered even if I request with AJAX. So I renamed the template file and tried to load it on demand in search.php: if ($config->ajax) { header("Content-type: application/json"); // Set header to JSON echo $matches->toJSON(); // Output the results as JSON via the toJSON function } else{ $factory = $modules->get('TemplateEngineFactory'); $view = $factory->load('search-results.tpl'); echo $view->render(); exit; } search-results.tpl {extends file="main.tpl"} {block name="content"} <h1>{$page->title}</h1> {$content} {/block} Now my AJAX response works and the template gets rendered BUT it seems that variables assignments which I do in the _init.php are not executed. For example I set the browsers title and the main menu structure there, but the menu or the title do not get rendered, although _init.php is prepended because if I do an echo there, it displays on the page. I hope somebody can help me with this problem. EDIT: Solution is to just exit at the end of the AJAX clause, so the template does not get rendered if ($config->ajax) { header("Content-type: application/json"); // Set header to JSON echo $matches->toJSON(); // Output the results as JSON via the toJSON function exit; }
-
The problem with your approach is, that it only requests the data once and ProcessWire returns all pages instead of those who match the query string. This could be a problem on very dynamic sites, where the content changes often. Here is my solution which solves this: Modify the standard search.php and add if ($config->ajax) { header("Content-type: application/json"); // Set header to JSON echo $matches->toJSON(); // Output the results as JSON via the toJSON function } so the whole file reads <?php namespace ProcessWire; // look for a GET variable named 'q' and sanitize it $q = $sanitizer->text($input->get->q); // did $q have anything in it? if ($q) { // Send our sanitized query 'q' variable to the whitelist where it will be // picked up and echoed in the search box by _main.php file. Now we could just use // another variable initialized in _init.php for this, but it's a best practice // to use this whitelist since it can be read by other modules. That becomes // valuable when it comes to things like pagination. $input->whitelist('q', $q); // Sanitize for placement within a selector string. This is important for any // values that you plan to bundle in a selector string like we are doing here. $q = $sanitizer->selectorValue($q); // Search the title and body fields for our query text. // Limit the results to 50 pages. $selector = "title|body%=$q, limit=50"; // If user has access to admin pages, lets exclude them from the search results. // Note that 2 is the ID of the admin page, so this excludes all results that have // that page as one of the parents/ancestors. This isn't necessary if the user // doesn't have access to view admin pages. So it's not technically necessary to // have this here, but we thought it might be a good way to introduce has_parent. if ($user->isLoggedin()) $selector .= ", has_parent!=2"; // Find pages that match the selector $matches = $pages->find($selector); $cnt = $matches->count; // did we find any matches? if ($cnt) { // yes we did: output a headline indicating how many were found. // note how we handle singular vs. plural for multi-language, with the _n() function $content = "<h2>" . sprintf(_n('Found %d page', 'Found %d pages', $cnt), $cnt) . "</h2>"; // we'll use our renderNav function (in _func.php) to render the navigation $content .= renderNav($matches); } else { // we didn't find any $content = "<h2>" . __('Sorry, no results were found.') . "</h2>"; } if ($config->ajax) { header("Content-type: application/json"); // Set header to JSON echo $matches->toJSON(); // Output the results as JSON via the toJSON function } } else { // no search terms provided $content = "<h2>" . __('Please enter a search term in the search box (upper right corner)') . "</h2>"; } Then call typeahead with the following options: $.typeahead({ input: '#q', order: 'desc', hint: false, minLength: 3, //cache: false, accent: true, display: ['title'], // Search objects by the title-key backdropOnFocus: true, dynamic: true, backdrop: { "opacity": 1, "background-color": "#fff" }, href: "{{url}}", emptyTemplate: "No results for {{query}}", searchOnFocus: true, cancelButton: false, debug: true, source: { //url: actionURL // Ajax request to get JSON from the action url ajax: { method: "GET", url: actionURL, data: { q: '{{query}}' }, } }, callback: { onHideLayout: function (node, query) { $('#searchform').hide(); console.log('hide search'); } } }); The important parts are "dynamic:true" and the "source" configuration so the query string is beeing sent. Now you have a nice AJAX search. EDIT: If you also want to find the query string in other fields than the title make sure you add filter: false to the config of typeahead.
- 7 replies
-
- 8
-
- typeahead
- autocomplete
-
(and 2 more)
Tagged with:
-
Finally better editing of environment variables like path in Windows 10 Build 1511. Nice https://t.co/vwfxBsLY2J
-
Finally better editing of environment variables like path in Windows 10 Build 1511. Nice :) https://t.co/vwfxBsLY2J
-
@kongondo Thank you for clarification. It works in my multilingual site if I use it with an ID: $menu->render($pages->get(1126), $options) But now another problem occurs. There are several empty A tags between my menu items with this configuration: $menu = $modules->get('MarkupMenuBuilder'); $defaultOptions = array( 'wrapper_list_type' => 'div',//ul, ol, nav, div, etc. 'list_type' => 'a',//li, a, span, etc. 'menu_css_id' => '', 'menu_css_class' => '', 'current_css_id' => 'active', 'divider' => '»',// e.g. Home >> About Us >> Leadership //prepend home page at the as topmost item even if it isn't part of the breadcrumb 'prepend_home' => 1,//=> 0=no;1=yes 'default_title' => 1,//0=show saved titles;1=show actual/current titles 'include_children' => 0,//show 'natural' MB non-native descendant items as part of navigation 'b_max_level' => 1,//how deep to fetch 'include_children' ); $view->set('mainmenu', $menu->render($pages->get(1126), $defaultOptions)); $view-set is for assigning the menu to my smarty variable, in case you wonder. The output looks like <div> <a> </a><a href="/">Start</a> <a> </a><a href="/de/termine/">Termine</a> <a> </a><a href="/de/produkte/">Produkte</a> <a> </a><a href="/de/haendler/">Händler</a> <a> </a><a href="/de/ueber-uns/">Über uns</a> <a> </a><a href="/de/news/">News</a> </div>
-
Hi @kongondo. It doesn´t even work in PW 2.7.3. When I dump ($menu->render('mainmenu', $options)) to my Tracy Debug Bar in my main language, I see the generated code for the menu. As soon as I switch the language the output of the dump is false, the menu does not seem to exist. EDIT: When using standard processwire API in my smarty template, the titles are fine. {foreach $homepage->and($homepage->children) as $p} <li {if $p->id == $page->id} class="active"{/if}><a href="{$p->url}">{$p->title}</a></li> {/foreach}
-
Hi @kongondo, I try to use this module with a multilanguage site with ProcessWire 3.0.15 (devns), but when I switch the language the menu does not show up. It only appears on the default language (german). Here is the code I used: $menu = $modules->get('MarkupMenuBuilder'); $options = array( 'default_title' => 1,//0=show saved titles;1=show actual/current titles ); $menu->render('mainmenu', $options)); The titles of the pages that are in the menu are translated in ProcessWire. Any suggestions what I can do to get it running?
-
could not get post value submitted from another page
dotnetic replied to adrianmak's topic in General Support
Please mark your post as answered, as it would help others to see directly, that no further action is required.