Jump to content

gebeer

Members
  • Posts

    1,386
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. I'm using good old "compass watch" in the terminal from within my template folder to compile my SASS/SCSS. So I don't need any other tools than compass. A typical site/templates/config.rb (taken from my https://github.com/gebeer/site-pwbs profile) for compass looks like: require 'compass/import-once/activate' # Require any additional compass plugins here. add_import_path "bower_components/bootstrap-sass-official/assets/stylesheets" # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed
  2. gebeer

    Logo carousel

    In slick, if you set "autoplaySpeed" to something quite low (10 or so) and "speed" to something quite high (10000 or higher) you should get a nice result. See http://codepen.io/anon/pen/WQJPXr
  3. You could also accomplish this with pure CSS. Lets say your CKEditor content gets ouput in your template inside a <div class="maincontent">CKEditor content with <img> tags</div> If you are using SASS version of Bootstrap, in your scss you can do .maincontent img { @extend .img-responsive } If you are using plain CSS (taken from the img-responsive class) .maincontent img { display: block; max-width: 100%; height: auto; }
  4. Hello, I would like to utilize wire/modules/Inputfield/InputfieldIcon/ in a module. I found that icons.inc there does not include all FontAwesome 4.4 icon classes. Is the selection of icon classes in icons.inc opinionated for use in PW or is it just not up to date? Anyways, I put together some code to produce a icons.inc with all available FA icon classes from master branch, sorted alphabetically: <?php $url = "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml"; $faArray = yaml_parse_url($url); // pack all icon ids (classnames) in array and sort alphabetically $iconClasses = []; foreach ($faArray['icons'] as $key => $row) { $iconClasses[$key] = $row['id']; } array_multisort($iconClasses, SORT_ASC, $faArray['icons']); // write all fa classnames to a file $file = "icons.inc"; $prefix = "fa-"; $out = fopen($file, "w+"); foreach ($iconClasses as $c) { $class = $prefix . $c . PHP_EOL; // echo $class . "<br>"; fwrite($out, $class); } fclose($out);
  5. I am converting a Joomla/Seblod install and in that process developed a widget system quite similar to Marcrura's. In Joomla widgets are called modules and in that particular install those modules were used quite a lot. To render modules (widgets) in Joomla you do something like <?php if ($this->countModules('content_bottom')): ?> <div class="content_bottom"> <jdoc:include type="modules" name="content_bottom" style="inner" /> </div> <?php endif; ?> So I tried to find a way in PW to conditionally output widgets. In my widget template, I have widget positions and layouts as page fields, just like Marcrura shows. Plus a page field of type PageListSelectMultiple to determine on which pages to show the widget. And, like Berhard, I have a checkbox to determine whether to show the widget also on child pages. Instead of using includes for each widget position, I use switch case statements in my widget template // get layout $layout = $page->layout->name; // layouts switch ($layout) { case 'carousel': // code to render carousel markup echo $carousel; break; case 'teaser': // code to render teaser markup echo $teaser; break; // ... etc. I use the delegate template approach like in the default site template with an _init.php that gets prepended and a _main.php that gets appended and outputs variables that are being populated in the page templates. Here is the logic to render widgets in the main content area of my _main.php <main class="col-sm-<?php echo $contentwidth; ?> content equalHeight"> <?php if($above) { ?> <!-- widget position above --> <div class="above"> <?php echo $above; ?> </div> <?php } ?> <?php echo $content; ?> <?php if($below) { ?> <!-- widget position below --> <div class="row below"> <?php echo $below; ?> </div> <?php } ?> </main> $above and $below hold the markup for all widgets in that position on that page and are false if there are none. And this is the code I use to determine whether there are widgets in that particular position on that particular page. In my _init.php I first set all position variables ($above, $below etc.) to false. (module translates to widget here) // Set all module variables to false foreach ($pages->find('template=modulepositions_items') as $position) { ${$position->name} = false; } The widget position pages all have the template modulepositions_items. So I iterate through all positions and then use Variable variables to create the position variables ($above, $below etc.) and set them to false. This step is needed to avoid PHP "Undefined Variable" notices. In my _main.php I store the widget markup in the position variables before all the other template markup (again module translates to widget) // get modules $modules = $pages->find('template=module, sort=sort'); // render modules in their positions foreach ($modules as $module) { // if module is assigned to this page or it's parent, render it on it's position if (count($module->onpages) == 0) { // if no specific pages are assigned, render module on all pages ${$module->moduleposition->name} .= $module->render(); } elseif ($module->include_children == 1 ) { if ($module->onpages->has($page) || $module->onpages->has($page->parent('id!=1'))) ${$module->moduleposition->name} .= $module->render(); } elseif ($module->include_children == 0 && $module->onpages->has($page)) { ${$module->moduleposition->name} .= $module->render(); } } Lets brake this down: "onpages" is the page field in my widget template that determines on which pages to show the widget. ${$module->moduleposition->name} .= $module->render(); renders the markup $module->render() of the widget and adds it to the position variable ${$module->moduleposition->name} which again is a variable variable (just like that expression too much ) The if and elseif statements check whether the widget should be rendered on that particular page. They feel a bit clumsy and I think I will change my setup to using the selector field instead. To summarize: with this method you get a quite flexible widget system with the benefit of minimizing the code used to render them in _main.php and the possibility to have conditional markup depending on whether there are widgets for that position or not. Thank you guys for sharing your approaches which gives me some good ideas for improving on my own.
  6. Hi Roych and welcome to the forum! There is Damienov's function for rendering a bootstrap 3 dropdown menu. So no need to reinvent the wheel You need to include that function somewhere in your template. E.g. you could make a file functions.php and put that function inside and save it to site/templates/inc/functions.php. Note that this part does NOT belong in your functions.php, only the function itself: // bundle up the first level pages and prepend the root home page $homepage = $pages->get(1); $pa = $homepage->children; $pa = $pa->prepend($homepage); // Set the ball rolling... echo renderChildrenOf($pa); Then in your main template or even in your init.php file you include the function: /* * Include any other shared functions we want to utilize in all our templates * */ require_once("./inc/functions.php"); Now in your template were you want to render the function you put this part: // bundle up the first level pages and prepend the root home page $homepage = $pages->get(1); $pa = $homepage->children; $pa = $pa->prepend($homepage); // Set the ball rolling... echo renderChildrenOf($pa); This should render a nice BS dropdown navigation.
  7. I need to revisit this thread because the problem has given me a headache agein today. It seemed like $page->render($options) cannot be used with the delegate approach where you assign your content to a variable in your template file and _main.php gets included and renders that variable. Here my setup to test this behaviour: basic_page.php <?php $gallery = $page->children()->first(); content = $gallery->render(array("useMain" => false)); $gallery has template gallery.php <?php if (isset($options['useMain'])) $useMain = $options['useMain']; $content = "<h2 class='page-header'>{$page->title}</h2> {$page->bodycopy}"; With this setup "$gallery->render(array("useMain" => false));" returns an empty string. if I change gallery.php to <?php if (isset($options['useMain'])) $useMain = $options['useMain']; // NOTE THE echo instead of $content = echo "<h2 class='page-header'>gbr{$page->title}</h2> {$page->bodycopy}"; Then I get the string that I would expect from "$gallery->render(array("useMain" => false));" So the culprit seems to be the $page->render($options) method not returning my $content variable from the gallery.php template. The solution is dead simple, though. gallery.php: <?php if (isset($options['useMain'])) $useMain = $options['useMain']; $content = "<h2 class='page-header'>{$page->title}</h2> {$page->bodycopy}"; if (!$useMain) echo $content;
  8. @IntegralHack You can find the code to get you started towards the end of post #10 in this thread. Of course, you would need to define your classes (in the example the classes are in /models/Product.php) that have the actual code for getting, putting, posting and deleting values. If you need to see some more code, PM me. It would be much appreciated if you could share some of the tricks and what the new things in PW are that you are talking about
  9. Hello, I was getting a setOutputFormatting error for a CKEditor field that had Content Type set to "Markup/HTML with image management" while trying to save HTML to that field in the course of importing about 150 pages through the API. This happened although $p->of(false) was set. It took me quite a while to figure out that this error was thrown only when there were image tags in the HTML that should be saved to that field. Then I went and switched Content Type for that field to "Unknown". Now the import worked fine. After switching Content Type back to "Markup/HTML with image management" and running the import again, there were no errors anymore. I just thought I'd mention this here in case someone else is facing similar problems. This happened on a 2.6.15 dev install.
  10. @adrian This seems to be a multilanguage issue. Changing the name of the homepage also changes the path of all children. Would be great to have checkbox like that.
  11. http://www.lovemysurface.net/run-linux-on-surface-pro-3/ Should be possible on the Pro 4, too
  12. @mike_b thanks for posting this fix here. Actually I never had used this profile for a site that required IE8 compatibility. So I never tested for that. For quite some time now I am using my other, more advanced Bootstrap 3 SASS Fontawesome Blank Site Profile. This one I abandoned in favour of the SASS version which gives much more flexibility and up to date framework code.
  13. I just discovered that after my client had changed the title of the HOME page, the URL for that page got changed accordingly. Now all pages in the tree got new URLs which is not good for search engine indexing at all. Maybe you could add an option to disallow automatic changes for the name of the homepage?
  14. Hello, I have setup multiple templates for users on a 2.6.17 install. My user template is "therapeut". I added a new role "admin" with following permissions set Now when I login with user role "admin", I cannot edit the userpage "harald-roeder" with template "therapeut" through the page tree. But I can edit the same userpage through Access->Users->harald-roeder. Is this a bug?
  15. Thank you, found it in Advanced tab Exactly what I was looking for. So no need for Soma's module anymore. But still, I find it confusing that the name field is not editable from the Basics tab.
  16. In the user template (or clones of it) there is no field "name". I have set $config->advanced = true;
  17. Thank you Soma for this module. This is quite some time ago. For 2.6.x versions of PW, is there a way to change the label without having to use a module? I can't find this field anywhere, even with "$config->advanced = true;"
  18. Thank you all for your suggestions. @horst I'm already storing sessions in the DB. Will have a look into the ini settings. Meanwhile I found and interesting article which talks about using "session_write_close();". I will do some more research and post my findings here.
  19. Yeah, would be great if we could decide on a template basis whether to use sessions or not.
  20. Thanks for the answer. I see that there is a config setting "$config->sessionExpireSeconds" which defaults to 86400 seconds. Would it make any difference to the server load to reduce the session time? Or does nayone have an idea how to deal with the situation?
  21. Hello all, I am using part of a PW install as a backend for a RESTful API. Everytime a client consumes the API, a session is started. The RESTful approach is sessionless per definition and I would like to avoid sessions, if possible, for performance reasons. When I look at the open sessions while only one client is getting or putting data through my REST API, I can see that there are quite a few (over 50) sessions open from that client. The project is at a testing stage right now and I'm afraid that once 50 or 100 clients are connected, the sessions will put a big load on the server. Is it advisable at all to try and avoid sessions? How would I go about killing sessions or, even better, connect to my API endpoints without starting a session in the first place?
  22. Hello everyone, for a project that is utilizing ProcessWire as a web frontend and REST API backend, we are looking for a hybrid app developer. ATM our client has native Android and iOS apps that exchange data trough a REST API with the ProcessWire web app and then display that data on the mobile clients. We are looking into possibilities of dropping the native apps and working with a hybrid app instead. The project is long term. The web frontend and REST API is already up and running, though at an early stage. I can't get further into details here. Please PM me if you are interested and I will share more details. Thank you.
  23. @TLT happy to here that you like my profile I tried to keep everything as minimal as possible. That is why the collapse plugin is not included in plugin.js by default. But, thinking about it, it makes sense to include it by default. I will amend and update the profile on github. EDIT: profile is now updated on github
  24. First off, thank you for this great module. I have installed the latest version (0.8.2) and assigned one template (workshop) I'm doing import of pages from a Joomla site and want to set values for SEO fields through the API. But I get this message when trying to save data to SEO fields: "Notice: Indirect modification of overloaded property Page::$seo has no effect in /var/www/qgtpw/site/templates/convert.php on line 225". My code $data = csv_to_array('inc/joomla_workshops.csv'); foreach($data as $csv) { $jid = $csv['id']; $title = $csv["title"]; $description = $csv["metadesc"]; $keywords = $csv["metakey"]; $workshop = $pages->get("template=workshop, jid={$jid}, include=all"); if ($workshop->id) { $workshop->of(false); var_dump($workshop->seo); if ($title != "") $workshop->seo->title = $title; if ($description != "") $workshop->seo->description = $description; if ($keywords != "") $workshop->seo->keywords = $keywords; $workshop->save(); $wokshop->of(true); echo "$jid<br>"; } } The var_dump gives "null"; How would I go about saving data to the SEO fields via the API?
×
×
  • Create New...