-
Posts
2,765 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
shouldn't be that hard; i've done some similar things with complex displays really similar to that. this is untested and assumes a lot, not knowing the names of fields etc.. <? function listMovies() { // get all of the movies $movies = wire("pages")->find("template=repeater_movie_times") $dates = array(); $out =""; // find the array of dates for all movies foreach ($movies as $movie) { $dates[]= date("U", $movie->getUnformatted("date")); } $dates = array_unique($dates); asort($dates); // for testing // print_r($dates); // print_r($movies); foreach($dates as $key => $date) { $dateDisplay = date("l, F jS", $date); // l = A full textual representation of the day of the week // F = A full textual representation of a month, such as January or March // j = Day of the month without leading zeros // S = st, nd, rd, th // Output the date $out .="<h2>{$dateDisplay}</h2>"; // find the array of movies this day and put into new array $date_movies $date_movies = $movies->find("date=$date"); // print_r($date_movies); // loop through the movies for this day and add the times to the array $times = array(); foreach ($date_movies as $date_movie) { $times[]= $date_movie->start_time; } $times = array_unique($times); asort($times); // print_r($times); // loop through the times and find movies for the time foreach($times as $key => $time) { // Output the time $out .="<h3>{$time}</h3>"; // filter only the movies for this time, from the $date_movies array. $time_movies = $date_movies->find("start_time=$time"); // print_r($time_movies); echo '<ul>'; foreach($time_movies as $m) { $movie = $m->getForPage(); $out .="<li>{$movie->title}</li>"; } // end foreach movies echo '</ul>'; } // end foreach times } // end foreach dates return $out; } ?>
- 1 reply
-
- 1
-
your options for a slider are several.. here are two common options: 1.) Repeater - the repeater is a type of field that can repeat the same content pattern over and over on a page. You can specify which fields to use in the repeater. repeaters are really pages, that are just hidden from the normal page tree. I was just working on a site where their homepage slider is done with a repeater. You don't hear much about them now that there is Page Tables, tables, and profields multiplier; however repeaters are still an indispensible part of the the PW toolkit and when used for the right purpose are great. 2.) Pages, and PageTable You can setup a hidden branch of the page tree (e.g. settings) and below that store various things, one of which could be sliders; so you would have something like: /settings/slider/slide1 /settings/slider/slide2 the template for slider could be called 'slide-folder', or 'slide-index' and then template would be 'slide'. your slide template would have whatever fields you need. the slides themselves will be added by the pagetable field Next you would setup a pageTable field called slides and you would specify that the new slides are added to that /settings/slider/ branch.
-
cool... will do some testing and report back; wondering if this should be documented somewhere, because i can see people assuming that the WireArray would differentiate images with the same name if they were keyed to different pages..
-
the only thing worth mentioning with Piwik is that since it is self hosted, if you have some other sites using it (i have a lot of sites all using the same piwik install), sometimes i have noticed a delayed page load on some sites while it waits for the piwik server to respond; maybe there is a way for me to configure this better, but i would guess that if you are going to use piwik as a personal analytics server, to have it somewhere on the cloud to avoid loading delays on the referencing sites..
-
I think i may actually require that these go directly into WireArray, because when they are being output, i am using a lot of the properties, like $image->page, and then all of the inherited fields of the page that the image was pulled from; if i were to put them into a plain array, i would lose the $page property... maybe there needs to be a parameter for import which allows duplicates, especially in the case of page images? EDIT: or maybe your example does preserve the properties, with the getArray() ? will have to get more up to speed on that..
-
I was using import - is that the reason why it was de-duplicating on the file name? this is the code $productImages = new WireArray(); foreach( $page->children as $p ) { $productImages->import($p->product_images); } $productImages->import($page->product_images_master);
-
came across a strange edge case; I'm creating a new WireArray to collect images from various pages, which all get output into a gallery. In this particular site, the client had several images all with the exact same name on different pages, and when those were imported into the WireArray, they are de-duplicated, even though they are different images on different pages, so those images were not showing. I worked around it by renaming the images on the fly, and i can use the custom upload names to prevent this from happening in the future, but it does seem like someone else might run into this, not realizing that the wireArray is assuming the same named images are the same on import; i guess maybe i could have imported them into the wireArray using this syntax? $key = 0; foreach($p->product_images as $image) { $productImages[$key] = $image; $key++; }
-
that's pretty strange...have you tried copying out the entire text of the page 2 into a text editor and then pasting it back in?
-
yes, you'll have to do some additional checking in the function - i usually would add additional conditions, something like this: <?php class SiteUtilities extends WireData implements Module { /** * Basic information about module */ public static function getModuleInfo() { return array( 'title' => 'Site Utilities', 'summary' => 'Various utility functions', 'href' => '', 'version' => 1, 'autoload' => true, 'singular' => true ); } public function init() { $this->pages->addHookAfter('save', $this, 'AssignCatToSubcat'); } public function AssignCatToSubcat($event) { $page = $event->arguments[0]; if($page->template != 'thing') return; if($page->cat == '') return; if($page->subcat == '') return; $category = $page->cat; $subCategory = $page->subcat; $subCategory->setOutputFormatting(false); $subCategory->cat = $category; $subCategory->save(); } }
-
should be really simple; this is untested, but this is basically the idea: <?php class SiteUtilities extends WireData implements Module { /** * Basic information about module */ public static function getModuleInfo() { return array( 'title' => 'Site Utilities', 'summary' => 'Various utility functions', 'href' => '', 'version' => 1, 'autoload' => true, 'singular' => true ); } public function init() { $this->pages->addHookAfter('save', $this, 'AssignCatToSubcat'); } public function AssignCatToSubcat($event) { $page = $event->arguments[0]; if($page->template != 'thing') return; $category = $page->cat; $subCategory = $page->subcat; $subCategory->setOutputFormatting(false); $subCategory->cat = $category; $subCategory->save(); } }
-
this is a common situation; you have a page field, and you create a new page by adding the options there on the ASM select, but you need some other things to be configured on that page, in your case the category). concerning your first request - the title, that should be set by the option you have entered, as long as you have configured it that way; but if you need more options those can be adjusted on page save using a module; here is an example which you would need to put into a module; for example, i always have a generic 'SiteUtilities' module where i can throw in all kinds of generic stuff without having to make multiple modules, and worry about installing them or keeping track of them; <?php class SiteUtilities extends WireData implements Module { /** * Basic information about module */ public static function getModuleInfo() { return array( 'title' => 'Site Utilities', 'summary' => 'Various utility functions', 'href' => '', 'version' => 1, 'autoload' => true, 'singular' => true ); } public function init() { $this->pages->addHookAfter('save', $this, 'AssignSubCategory'); } public function AssignSubCategory($event) { $page = $event->arguments[0]; if($page->template != 'someTemplate') return; // the template where you want this to run $category = $page->category; // this would be your category field $subCategory = $pages->get("something"); // this would be the page that is the sub-category foreach($category as $c) { if($c->template != 'category') continue; $c->setOutputFormatting(false); $c->sub_category->add($subCategory); $c->save(); $this->message("Sub-category {$subCategory->title} added to Category{$c->title} "); } } } // end class
-
i did have the save to 404 error a few times; it was totally random when it happened; i believe it was a mod security issue with my host.
-
@laban, just change the page select from a multi to single and it should fix your issues
-
Looking for a Card Based Layout or Template
Macrura replied to NooseLadder's topic in API & Templates
there's really nothing to it... you just need a way of rendering the objects, like a function or include file, or template render; I have a site that i do an isotope 'wall' homepage, and it pulls in all of the site content, and renders each wall item with a different function depending on the template of the page.. the isotope/masonry is pretty well documented and easy to use, if you're planning on using that; -
i don't get this: $menuname = $page->show_menu->select_value; if you want the name then it would be: $menuname = $page->show_menu->name; you could also setup a fallback in case you haven't made show_menu required, like: $menuname = $page->show_menu->name ?: "home-menu"; oops - almost forgot: welcome to the forums, and to processwire!
-
some guesses: 1.) is $page defined where you are doing this and does that page's template allow the new page to be a child of it? 2.) maybe original-page needs trailing slash?
-
Help getting a custom styles php file working
Macrura replied to onjegolders's topic in General Support
i don't think ProCache is overwriting the header - i think that it is serving the file that is generated from a .html file in the cache, and since those files are .html , they will always be sent as text/html; would be curious if there were some magic htaccess way to make it work- 15 replies
-
- 1
-
- css
- custom styles
-
(and 1 more)
Tagged with:
-
@Marty - maybe this could help: http://ckeditor.com/forums/Support/Solved-I-cant-embed-tweet-with-the-new-version-4.1.1 also this plugin might be cool: http://ckeditor.com/addon/mediaembed doh! adrian is 1 step ahead
-
https://processwire.com/talk/topic/8525-cant-import-polymer-elements/
- 3 replies
-
- 2
-
- webcomponents
- polyfill
-
(and 3 more)
Tagged with:
-
@Peter - how many hanna codes do you usually use on the average site? My usage has been maybe 4-5 hanna codes on a site, or maybe as many as 10 on a really complex/large site; I do think maybe tags could help here on this page in terms of organizing them, but also i don't expect my clients to be interacting with the hanna codes list so this would be more of an admin convenience. sounds trickier than the templates, b/c the hanna codes are used randomly within text areas, or text fields - and are processed at runtime to the output; not that it would be impossible, but it might be a process that needs to run to collect all of that data and could take a lot of processing depending on the # of pages in the site.. I do agree some module to get a "hanna code report" than could generate and be able to process something like 50-100 pages at a time before generating the entire report; this could be very useful, because we might want to see where a particular one is being used; personally I always try and come up with solutions that avoid hanna codes if at all possible and are equally easy and potentially more elegant, and as such i never have more than a handful of hanna codes per site; Perhaps some of your hanna codes could be replaced with other solutions? they are always sort of a risk being that they are inserted into RTE, so not as bulletproof as something like a validated text input.. I always provide complete documentation for all hanna codes including the code itself that can be copied and then usage instructions, using my docs and docs tab system, as well as often inline using the Markup Textareas, so from the end user perspective, they can use any available hanna code right on the page (or also input with the helper module); but i do think that having a description field would be handy, especially if you come back to a project after some time, you could see more easily what each one does, at a glance..
- 3 replies
-
- 1
-
- UI
- Management
-
(and 2 more)
Tagged with:
-
(This is just my opinion and may not be 100% technically accurate, but here it goes) You shouldn't have any issues installing and using processwire, and based on your posts, the only way I can recommend for you to get a clean install is to completely sequester your PW install from all other things on your hosting; so in short: 1.) Create a subdomain from cpanel, and make sure it uses a folder not within any other currently used folder (e.g. not a folder inside your public_html) 2.) setup a new clean database only for PW (for example using mysql database wizard) 3.) upload latest dev of PW into your new subdomain folder 4.) access your subdomain from mysubdomain.mysite.com and run the install post back any errors you see here
-
sometimes i do wigets with functions, sometimes with render, and sometimes with includes, the latter being explained here: https://processwire.com/talk/topic/8635-simple-example-for-widget-management/
- 8 replies
-
- widgets
- page field type
-
(and 1 more)
Tagged with:
-
one of the first pieces of wisdom i got from Soma was about making a template from where you can execute api stuff; this is needed on every site, because you'll always need some "api playground" where you can test things and run things to change, add, fix content.. my setup is to have a template called tools, and then a subfolder in the templates where i store all of the scripts that i will run on that tools template, then i just include the one i'm currently using into it and go from there. Sometimes when developing a new part of a live site, i can just clone a template, run it under tools and set the virtual page to anything in the site (example, $page = $pages->get(1012); ) but mostly i'm doing complex imports from other systems like joomla, or from spreadsheets with a lot of custom stuff and dependant/related pages, formatting etc..
-
@grumpy - right, that is quite a lot of info. Having just now taken a quick look at TNG, both the public and admin demos, i think it would be good to make some points: 1.) The TNG is already it's own CMS of sorts: It has it's own database, admin panel, and it generates a complete frontend website. How this is to be integrated with another CMS is something you have to figure out or plan. Options could include importing all of your TNG data into Processwire, and using it alone as the system for the genealogy; this could be a pretty big task depending on how many of the features of the genealogy system you use. But since you can build just about anything with PW, that is an option. BTW - You may have noticed that there is already a Wordpress integration for it. Not that I would like to steer you away from Processwire, but at the least I think you should look at that option, since it may work 'out of the box'... Processwire itself isn't going to generate any markup for you in terms of the mobile sites, aside from the basic responsive demo frontend it comes with.. Let me know if there are some more specific questions or issues that can be addressed!