Jump to content

Search the Community

Showing results for tags 'template'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







  1. I have been looking into this for awhile, but really have not found any module or "template" that handles this. On my test site I have about 80 pages (some nested and some as parents), which is really making the page tree a bit cluttered. I was wondering if anyone else had seen/used a template/module to make the page tree a little more "user friendly" and a bit less cluttered. I know I could probably create a new admin layout for this, but I had no idea where to start.
  2. So I have set up a pretty basic template for pages using: <?php include('header.inc'); ?> and page structure is something like mydomain.com/whales/page-name I was hoping to have a different header.inc for every group of pages (so based on the parent page include the relevant header.inc). For example, /whales/ would have a different header than /goldfish/ (sorry for the silly examples). However, I can not for the life of me find a solution, nor am I having any luck in creating the desired outcome. Has anyone done anything like this before? Am I approaching this is the wrong way?
  3. Hi everyone, I'm starting to code PW side of my first ever PW project. Really excited to see how it goes. While starting out I'm planning a template approach to use in the project mostly relying on wireRenderFile method. As it is my first project I wanted to make sure this won't cause me problems in the long run. Here is how I started out: I have two functions in _func.php as helpers. One of them is wrapper for wireRenderFile and the other is appender for $content for not using $content .= everywhere I have a global variable called $site. I normally avoid global variables but in this case I'll only have one and its not so different than using $homepage or $title before the includes (or is it??). I'm thinking about making a module for this to keep _init.php clean And in the _main.php my code is like that, with the common areas for pages. For the content of pages, I echo $content for the page content I gathered. For example, for basic-page template file: You can see usage of both functions here. That's all for the start. I'm trying to keep it simple to prevent going out of my hand. Do you see any "do not" or "should not" points here, or have any kind of recommendations? Thanks ahead
  4. Short question: Is it possible? Longer explanation: I have a rather big product cataloque which is viewable for registered users only. We now want to open it to the public. In the valued spirit of "I'd rather take 30 minutes to script something than 20 minutes to do it manually" I am looking for a way to change the access of 50 or so templates to "viewable for guest" but I can't find an API method. Can anyone help? Thanks, thomas
  5. I have a question on how to group search results by template, with pages sorted alphabetical (as standard) in each group. I have a film blog running ProcessWire. It has lots of posts, ratings, categories, ratings, directors, actors and tags, my search result is getting crowded by all this pages after a while. These pages have different templates. Until now I have had badges with the template label by their title in the search result. I am wondering if there's a simple way of coding it to group the search result, kind of like how IMDb does it: Titles are grouped first, then names second. Like this. To illustrate, here's a part of my structure, template name in brackets: --- Main (home) Blog (posts) Movie 1 (post) Movie 2 Actor (actors) Actor 1 (actor) Actor 2 Director (directors) Director 1 (director) Director 2 Tag (tags) Tag 1 (tag) Tag 2 --- And here's how I would want my search result to show, e.g. if all these pages where to mention Tom Hanks somehow: --- Movies: Movie 1 Movie 2 Directors: Director 1 Director 2 Tags: Tag 1 Tag 2 Actors: Actor 1 Actor 2 --- I am in a learning process, and I am sure there are other problems that will appear when considering usability. Limits within groups, etc. But for now this is a way of sorting that I might also want to use elsewhere later on. Whereas I have headings and results in separate lists. (PS: I have read a couple of posts on group sorting based on parent ID, but none of them was exactly what I was looking for.)
  6. Hi all! i have noticed that if enable the cache (for example on homepage), if I switch language the page is always the same, so i imagine that cache file is the same for any language. I wonder if there is any option that can save one cache file for each language. Alessio
  7. I can't seem to remove a template, I have a template called sitemap - and it reckons it's used by 1 page, however that page has been deleted yet it's not reflected - the 'search' filter also shows up no pages using that template, yet the template still things it's in use. Any way to fix this? cPanel with PW 2.6.1 regards John
  8. Hello everyone, Been working rough 5-6 months with this beast and i gotta tell you that it's almost perfect Of course every software has it's ups and downs, just like life does and nothing is perfect or meant for everyone, but here we go... I think database structure is about correct and flexible enough, what i don't like is that i can have similar field with 3x different prefix just because i need different control data for that same field. How about if template would control fields data instead of field? Field could have it's own control data as default, but i would really like to see that template could at least control some data, like visibility, appearance, required, stuff like this. Why? Because past 5-6 months i faced fact that for example when i need to custom admin interface for some template i would like to use same field over and over again, but it's kind of impossible when width can be 50%, 33% or 100% for different templates, data how ever is very same. Feels so stupid to create field over and over again, when it could use existing database tables. You already have control tables for fields and data tables separated, which is good model, so how big deal would this to be to implement something like this? If this already exists and i'm blind, lemme know and i'll buy you beer I hope i'm not the only one feeling like this, cheers for listening
  9. You want to display pdf files as pages in frontend? Go here: Create a template file 'showpdf.php' <?php $file = $page->pdf->filename; header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="' . basename($file).'"'); header('Content-Length: ' . filesize($file)); readfile($file); Create field 'pdf' of type file and add it to your template. Create a page using the template 'showpdf.php' Add pdf to page field 'pdf'. Done. To get save option instead of display use 'attachment' instead of 'inline' like header('Content-Disposition: attachment; filename="' . basename($file).'"');
  10. Is it possible to use a wordpress template or any template for processwire? I'm sorry. I'm a complete beginner to this codes. But I'm willing to learn. P.S. I'd like to use this template templatemo_372_titanium.zip
  11. Just found an article about templating and it really made me smile: Your templating engine sucks and everything you have ever written is spaghetti code (yes, you) I guess many people here on PW don't give much attention to templating engines as PW runns smooth even whithout one. But the concept of DOM Templating really looked interesting to me. I really would like to hear your opinions!
  12. I'm trying to fetch an array of pages that use a certain template with: $my_array = $pages->find("template=xxxx"); But for some reason, it won't return anything for the template that I'm targeting. If I change the template name to my basic page or news templates, for example, I get a list of pages output, but not for the template I want. Is there some setting I've inadvertently set that would cause the template's pages to not display? The template is being used for pages on the site and they display OK as single entry pages. Or could it be related to an issue I had with the same template yesterday where I was adding a new field to the page, and then when I went to edit the page with content in the new field, I'd get returned to the same page I was on, i.e. /processwire/page/edit/?id=XXXX but it would display the 404 template instead? And the data I'd tried to enter wouldn't be saved. The template only has title, multiplier, table and file fields attached to it. And the table field is also modified by the TableCSVImportExport module.
  13. Hi, Is there a way we can make the Selectorfield to choose system templates ? Currently I have created a Selectorfield and added to a template. Now when I create the page, the selector only shows the templates that are not system templates. I would like to show the system templates also in the list if possible.
  14. Hi there, I've created this sample home page As you can see there are some repeating parts (wide image, heading etc.) but they are all followed by a part that differs from the rest. Notice also that the top wide image is higher than the other two. For the images I use the CroppableImage module (it's in alpha but so far it looks stable). For my client I want the admin as simple, intuitive and logical as possible. What would be the best practice to set up the back-end template. Thanks Alfred
  15. Hi, recently I asked a question regarding the PageNameURL generator. Is it also possible to use the generator within a template to create urls out of field content? I have an array representing a list of names, some of them containing various special characters, i.e.: Tomas Tranströmer José Saramago Kenzaburō Ōe Gabriel García Márquez Halldór Laxness François Mauriac Władysław Reymont Now I'd like to create urls like: /author/wladyslaw-reymont or /author/kenzaburo-oe Is there a PageNameURL generator function I can use to convert the special characters? Thanks a lot! Sarah
  16. Hi all, again this a more or less PHP-related question: I'm trying to reuse renderNav from the blog.inc file as found in the blog profile. The function accepts parameters: function renderNav($headline, $items, $currentURL = '', $mobile = true) The comment sections says: @param array|PageArray $items May be an array of Page objects or array of ($url => $label) Taken as it is the function outputs the title of the page objects in $items which works fine BUT I would like to output it a different field value ($page->client instead of $page->title in my case). This is where I am stuck with my limited PHP skills. How can I make the function output another field value than $page->title? How would I "put together" an array that contains this field values so that I can assign it as key => value pairs to $items? Thanks
  17. Hi all, I'm trying to adapt the blog profile to my needs. In my template blog-list.php I have the following: $content = renderPosts("limit=10", true); which populates $content in main.php. renderPosts() I have taken as it is from blog.inc in the blog profile: /** * Given a PageArray of blog entries generate and return the output. * * @param PageArray|Page $posts The entries to generate output for * @param bool $small Set to true if you want summarized versions (default = false) * @return string The generated output * */ function renderPosts($posts, $small = false) { if(!$posts instanceof PageArray) { if($posts instanceof Page) { // single page $post = $posts; $posts = new PageArray(); $posts->add($post); } else if(is_string($posts)) { // selector string $selector = $posts; $posts = wire('pages')->find("template=blog-post, sort=-date, $selector"); } else { throw new WireException('renderPosts requires a PageArray, Page or selector string'); } } foreach($posts as $page) { if(empty($page->summary)) { // summary is blank so we auto-generate a summary from the body $summary = strip_tags(substr($page->body, 0, 450)); $page->summary = substr($summary, 0, strrpos($summary, ' ')); } // set a couple new fields that our output will use $page->set('authorName', $page->createdUser->get('title|name')); $page->set('authorURL', wire('config')->urls->root . 'authors/' . $page->createdUser->name . '/'); } $t = new TemplateFile(wire('config')->paths->templates . '/markup/posts.php'); $t->set('posts', $posts); $t->set('small', $small); $out = $t->render(); // if there are more posts than the specified limit, then output pagination if($posts->getLimit() < $posts->getTotal()) $out .= $posts->renderPager(); return $out; } As you can see, the function makes use of /markup/posts.php. Within posts.php I have the following: // display a headline indicating quantities $start = $posts->getStart()+1; $end = $start + count($posts)-1; $total = $posts->getTotal(); if($total) echo "<h3>" . sprintf(__('Posts %1$d to %2$d of %3$d'), $start, $end, $total) . "</h3>"; This echoes the quantities headline as expected to $content but I would like to have it echoed to my $sidebar variable instead which currently doesn't work as it is part of renderPosts(). My question: What would be the best strategy/solution to assign $total to my $sidebar variable instead to $content? Thanks
  18. I just installed ProcessWire for the first time and I've perused the documentation but haven't seen an explanation of the template files that start with an _. Can someone explain to me how those work? Also, how come they have an opening php tag but no closing tag? Is there anything that explains this in depth?
  19. I just got started with ProcessWire and am enjoying it so far. I followed instructions in a post by Ryan to set up an "author" role, but I have run into some trouble getting permissions for a template to take effect. Here is what I have done so far: Added the "page-publish" permission under the "Permissions" page. Created a role called "contributor" (instead of "author") for my website. The "contributor" role has the "view pages" and "edit pages" permissions checked. Created two templates called "articles" and "article" for individual posts. The access settings for the "articles" template for the "contributor" role has: "view pages" and "add children." The "article" template for the same role has: "view pages," "edit pages," and "create pages" checked. Created a page called "Articles" that is hidden and uses the "articles" template. I logged into a test user which has the "contributor" role and it just shows the "view" link when I click "Articles" in the page list. If I go to the "add" link path from the admin user for the "Articles" page and visit it under the test user, it says "you don't have access to add pages here." I would like the "contributor" role to be able to create new article posts, but the permissions did not seem to take effect. If anyone has any ideas on what to do, please let me know. Thanks for taking the time to read this.
  20. Is there a way of suppressing the automatic loading of the Templatefile? I was experimenting with Somas template approach https://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/ The problem is that you have to bend all Templates to a single file. I thought of putting the script into the _init.php($config->prependTemplateFile) That way you can use the default template structure. But if i do this, all templates get included again after _init.php is loaded. So now i am thinking about if there is a way to suppress that additional loading.
  21. Hi I am looking into ProcessWire to build an application. I am used to building applications that have db models separated out, which is nice and organized for building the application. I would also want to separate out a lot of the logic for the application(more in a Model View/Presenter fashion) and have seen some people are doing MVC with ProcessWire. But I wonder if I use pages, would this be similar to having models? I read somewhere that Users are pages in processwire, and user attributes can be fields of these pages. So maybe pages are one of the magic ingredients in PW? Can/should I do the same for other db models in the application(use pages as the models), or would I better be served by integrating an MVCmodule into PW, or using Laravel with PW? It's starting to seem like PW is a very different type of framework and can do all the MVC stuff, but in a slightly different paradigm, and that Pages are like the model, and Templates are the View/Presenter/Controller. And you could separate out the controller if you wanted to create some classes and implement some routing if you wanted.
  22. Hi all I have built my own module for processing forms on my site. The module does check to see of the request was forged or not, but I am unable to inset the token name and value into my template. I use Twig for my templates, and this is what I'm calling: <form data-form-ident="contact-form" data-form-token-name="{{ this.session.CSRF.getTokenName() }}" data-form-token-value="{{ this.session.CSRF.getTokenValue() }}"> The output for that is an empty string. Could it perhaps be because I am using Twig? Side note: disabling Twig is not an option as the templates I'm using are very complex - it would be a darn mission to revert to native PHP. (PW 2.4.0)
  23. Hi Forum, it seems as if I have a PHP question I'm unable to answer myself. I've tried for almost three hours now but I can't find the answer, why my code isn't working as it should. This is, what's going on: I have a central _functions.inc with this function: function renderReferenceList() { $page = wire('page'); $pages = wire('pages'); $page = $pages->get(1065); $page = $page->children("limit=15, sort=-date"); foreach($page as $child) { $out = "<div class='referenceTeaser post'>"; $out .= "<h3 class='articlehead'>{$child->headline}</h3>"; $out .= "<p>" . $child->summary . "<a href='{$child->url}'><i class='more'>Referenz ansehen</i></a></p>"; $out .= "</div>"; echo $out; } } Next I have a page template with this code: <?php include_once("./_functions.inc"); /** * Referenzen template * */ if ($page->id !== 1065) { $content = $page->body; $headline = $page->headline; $sectionhead = "Projekt"; $logo = $page->widget_logo; $logo = $logo ->single_image; $sidebar = "<div class='widget'>" . "<h2 class='sectionhead'>Kunde</h2>" . "<img class='logofile' src='{$logo->url}' title='$page->title' alt='$page->title' >" . "</div>"; } else { $sectionhead = "Referenzen"; $content = renderReferenceList(); } include("./_page.inc"); And I have a _page.inc with this code: <div id="main" class="grid-66 mobile-grid-100"> <?php echo "<h1 class='sectionhead'>$sectionhead</h1>"; if($headline) echo "<h2 class='articlehead'>$headline</h2>"; echo $content; ?> </div> <!-- /#main --> The problem is: The code for the else statement is working perfectly fine, it renders all div.referenceTeaser with the appropriate content, except that it does so on top of my markup directly after the opening body tag and not - as it should - within div#main ... var_dump($content=== null); returns true but no notice. What am I doing wrong? Thanks for your help before I'm going mad about this...
  24. I`m trying to tag a bunch of templates via the API (I mean tagging in the admin for sorting purposes). Is that possible? Coming from this post I tried this code, but it doesn't work: $p = $templates->find("name=post|posts"); foreach($p as $pt){ $pt->tag = 'blog'; $pt->save(); } Thanks!
  25. I'm working on a site with an about-the-team page where we have a sub-page for each different area of specialty. Each one of these pages will have a list of people who are in that specialty, this list built by pulling 'person' pages that were assigned to that specialty page through a page field. With me so far? Here's the fun part. I want to add a "level" to each of the people that show up on a specialty page. So let's say I'm on the Widget Managers specialty page, and I have the 'people' page field set to pull Alice and Bob to appear listed on this page. But I want Alice to be a 'senior' widget manager and Bob to be a 'junior' widget manager. I could just put a field in the Person page type that lets me set that person's level, but wait! A person can be assigned to more than one specialty page, with different levels on each one! So Alice might be a senior widget manager and a junior doohickey wrangler. She has to show up on the widget managers page as senior, and on the doohickey wranglers page as junior. Ideally, I'd have a repeater field containing two page fields, one to select a person and one to select their level on the current specialty page, but repeaters can't contain page fields. Anyone know of a way I might approach this?
  • Create New...