- 
                
Posts
7,529 - 
                
Joined
 - 
                
Last visited
 - 
                
Days Won
160 
Everything posted by kongondo
- 
	Glad you got it sorted. The blog templates are all for demo purposes. So you can edit them as you please, or even not use them (only using their code as a reference if you are new to coding/PW...). The CSS and JS folders are intentionally not copied over...(as explained in the read me )..
 - 
	Benjamin, That's what I said (sort of) in my post . CSS not nearly done (the links, the page title, etc...) . Went with your suggestion though, thanks.
 - 
	@caribou, I have been working on a commercial module that does exactly that (minus the thumbnails in the selected pages list). It is nearly done. A few things remain, such as the CSS. See screenshot below for a (unfinished-state) preview. I will try post a video demo later today. I'll be looking for beta testers so might PM you if you are interested. Thanks.
 - 
	Hi roblgs, Welcome to the forums and PW. Apologies for not getting back to you sooner. Sorry for the 'bad' start with the Blog module. The SQL error you see is something that started happening a couple of PW versions ago. It is safe to ignore it; just reload the dashboard and it will go away Blog automatically installs both MarkupBlog and ProcessBlog, although you may uninstall the former just fine 404s usually mean something wrong with your setup (server). URLs not being found where they are expected to be. I really doubt it has anything to do with Blog per se, but we are still going to help you Do other ProcessWire pages work fine? (Home, About, etc?) Is this a sub-domain? Is your install somewhere we can view it? (i.e. not a local install) Long shot, but try installing using the 'blank profile' Let us know how it goes.
 - 
	
	
				Remove duplicates in a foreach loop (but count them)
kongondo replied to Reid Bramblett's topic in Getting Started
You could filter them out in a temporary array...e.g. //example code $interests = $pages->find('template=poi, interests!=""'); //method 1 foreach ($interests as $int) { foreach ($int->interests as $p) {//interests is a multi page field; PW returns them as objects $array1[$p->id] = $p->title;//overwrite duplicate ids in the array key } } //method 2 foreach ($interests as $int) { foreach ($int->interests as $p) { if(in_array($p->id, $array2)) continue;//if we already have that id, skip it $array2[] = $p->id; } } //testing echo '<pre>'; print_r($array1); echo '</pre>'; echo count($array1); echo '<hr>'; echo '<pre>'; print_r($array2); echo '</pre>'; echo count($array2); Above are just examples. You could even store objects in the arrays, or create a temporary WireArray and store them in there. WireArray and PageArray docs: http://processwire.com/api/arrays/ Btw, the above code will not do the counting you want. That's easily doable as well... Edit: Reading your question again, this is probably not what you want...Oh well, code stays though.. - 
	
	
				2.6.16 publish date: Not yet in sort selector?
kongondo replied to thomas's topic in General Support
Look at my code...that's an in-memory sort (i.e. the sort is happening outside the database, after the items have already been fetched). In other words, and I should have been clearer, sort within the selector is not working for me either, just as you described - 
	
	
				2.6.16 publish date: Not yet in sort selector?
kongondo replied to thomas's topic in General Support
Haven't looked into the implementation yet but you are right; it seems not to be working. However, sorting the PageArray itself works for me, i.e. $pages->find('template=basic-page')->sort('-published'); Not exactly what you are after, but just thought to point that out... - 
	
	
				404 page should be optional for the page tree
kongondo replied to cb2004's topic in Wishlist & Roadmap
https://processwire.com/talk/topic/3843-how-to-define-the-404-page/ - 
	
	
				ProcessSlider - Image sliders for ProcessWire
kongondo replied to mauricius's topic in Modules/Plugins
Hi mauricius, Tried to install this on a PW 2.5.25 dev site and got the following error Fatal error: Class ProcessSlider contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ConfigurableModule::getModuleConfigInputfields) in F:\xampp\htdocs\dev\site\modules\MarkupSlider\ProcessSlider.module on line 648 I didn't have time to investigate further. Thanks. - 
	
	
				Mass create pages OR mass upload images and thus create pages
kongondo replied to a-ok's topic in General Support
@Richard, glad you got it sorted. Btw, I have another version that recursively searches through folders, sub-folders, etc....The Standard PHP Library (SPL)) is really cool- 12 replies
 - 
	
- 1
 - 
					
						
					
							
					
						
					
				 
 
 - 
	
	
				Module Module: RuntimeMarkup Fieldtype & Inputfield
kongondo replied to kongondo's topic in Modules/Plugins
Simple answer is that @Valan had a need and commissioned me to develop this . Seriously though, mr-fan already covered it brilliantly. When I get some time, I'll post some other examples. - 
	
	
				Mass create pages OR mass upload images and thus create pages
kongondo replied to a-ok's topic in General Support
UNTESTED, probably have some typos + poorly formatted code (I gotta run...) You want to add this to your template file....Wrap it around code that ensures only Superuser can load the code... //absolute path to a directory called 'tmp' within the site folder where we have our images $dir = $config->paths->site . 'tmp'; $addAndPublish = false;//true if you want to publish on save //prepare some variables we'll need later $a = 0;//for photo pages count $failed = array(); $parent =$pages->get('/portraits/'); $t = wire('templates')->get('your-portrait-template-name'); //if we found the directory (here we use Standard PHP Library (SPL)) if (is_dir($dir)) { $directory = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS); //iterate through each file in this directory foreach ($directory as $path ) { set_time_limit(30);//we try to avoid timing out //Remove and delete invalid file types $validImagesExts = array('jpg', 'png', 'gif', 'jpeg'); if($path->isFile() && !in_array($path->getExtension(), $validImagesExts)) { unlink($path);//we delete the invalid file continue; } //if valid image file we create a page named after it and later save it to the page if($path->isFile()) { //we are ready to start creating pages... $p = new Page(); $p->parent =$parent; $p->template = $t; $title = $path->getBasename('.' . $path->getExtension()); $p->title = $this->sanitizer->text($title); if (!$p->title) continue;//skip to next if no title found (just in case) $p->name = $this->sanitizer->pageName($p->title);//sanitize and convert to a URL friendly page name //check if name already taken if($p->parent->child("name={$p->name}, include=all")->id) { //if the same name already exists, add it to the $failed array [to display to user in error later] and skip to next title if ($path->isFile()) { $failed [] = $path->getFilename(); } continue; } //if add and publish is false, we save new page unpublished if (!$addAndPublish) $p->addStatus(Page::statusUnpublished); $p->save(); //add image to the page and save again $p->images_field->add($dir . '/' . $path->getFilename()); $p->save(); $a++; unlink($path);//we delete the temp file } }//end foreach //delete the tmp directory wireRmdir($dir, $recursive = true); //create a string of "failed" category titles to add to error message $failedTitles = implode(', ', $failed); //give the user some feedback... if($a > 0) echo 'Added' . $a . 'Portraits<br>'; if($failedTitles) echo 'Some Portraits not added because names already in use. These are:' . $failedTitles; }//end if (is_dir($dir))) else echo 'No Such Directory Found!';- 12 replies
 - 
	
- 7
 - 
					
						
					
							
					
						
					
				 
 
 - 
	Btw, thanks, your question made me realise that the code around the strip_tags need to be optimised anyway...That bit of code should only load when post small is set to true.
 - 
	Glad you got it sorted. Could I suggest that you direct the Autolinks question to Ryan? Maybe there's a way around the bottleneck...How many pages were you trying to load at once, btw?
 - 
	@Gazley, Must be at your end mate. I haven't encountered this nor read anywhere that strip_tags is slow. As you can see in this demo with +10K posts, showing 20 posts per summary page with a summary limit of around 500 words each and WITHOUT ProCache, PW loads the page in about 2 seconds.. http://demo.kongondo.com/blog/ And with shorter summaries: http://demo.kongondo.com/blog/posts/
 - 
	Is it solved then?
- 6 replies
 - 
	
		
- cache
 - directories
 - 
					(and 2 more) 
					
Tagged with:
 
 
 - 
	The answer is actually in the error message. Your assets directory seems to be locked down for writing. Does that happen only with Modules Manager or throughout your site? If the former, you might want to ask your question in Modules Manager support forum. There was a similar issue a while back. If the latter, have a read at this as well: https://processwire.com/docs/security/file-permissions/
- 6 replies
 - 
	
- 1
 - 
					
						
					
							
					
						
					
				 
 - 
	
		
- cache
 - directories
 - 
					(and 2 more) 
					
Tagged with:
 
 
 - 
	FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/ GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup As of 11 May 2019 ProcessWire versions earlier than 3.x are not supported This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin). The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen. The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages. The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan! Warning/Consideration Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API Backend Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer. FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. A very simple example. return 'Hello'; Simple example. return $page->title; Simple example with markup. return '<h2>' . $page->title . '</h2>'; Another simple example with markup. $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example. $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example. $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do: return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows: return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup') Access the field on the current page (just like any other field) echo $page->runtime_markup; Access the field on another page echo $pages->get('/about-us/')->runtime_markup; Screenshots Backend Frontend
 - 
	It is the title that ticked me off. For an 'experienced' publisher like tutsplus I expected at least the title to match the contents. For such a big outfit, my cynical side is telling me they knew exactly what they were doing....they know that was not an introduction to ProcessWire. Compare that to this introduction to Craft CMS. OK, so the authors are different but I expect articles are not published without going through some editorial process. Anyway, am good now... Edit: Ah, I see, Felix also commented about the Craft CMS intro...
 - 
	Thanks for that MichaMichaMicha, At first I was excited about the article...people have been waiting for this....Then reading it, it turns out (not-so-under the hood) this is an article about WordPress! What cheek! Underneath all the veneer about talking about PW, he/she is just bashing PW and not really saying much about its strength. Nothing about its raw power! I don't think the writer has even used PW before!! What a load of tosh! My frustration is not vented at you....but the writer of the article... That was supposed to be an intro...for crying out loud! .
 - 
	
	
				Module Module: Matrix Fieldtype & Inputfield
kongondo replied to kongondo's topic in Modules/Plugins
Sorry for the late response. I don't quite follow your question. Did you find a solution? - 
	
	
				Module Module: Matrix Fieldtype & Inputfield
kongondo replied to kongondo's topic in Modules/Plugins
@adrian, Just to let you know that I've added all your requests the module's GitHub issues so that I don't forget. As for the append vs overwrite issue, append seems to be quite tricky. It would need to find the last populated row and append from there. But finding out what the last row can be tricky, especially where we also allowed 'empty values'. I don't know if this makes sense. Anyway, will have a think about this one. Btw, the suggestion about custom PHP code to find row/column matrix pages is a powerful one and will lead to many possibilities, thanks. - 
	Just hit the refresh button...no need to uninstall..