-
Posts
807 -
Joined
-
Last visited
-
Days Won
10
Everything posted by kixe
-
Can I add information to the images displayed inside the body?
kixe replied to Xonox's topic in API & Templates
You can get the original size via API: // a page has an image field named 'image' $page->image->first()->size(50,50); echo $page->image->first()->width; // returns (int) 50 echo $page->image->first()->original->width; // returns (int) 1000 (original size) // if there doesn't exist a variation of the image the $original property returns null Learn more: https://processwire.com/api/ref/pageimage/#api-original -
Programmatic way to determine if field is multi-language?
kixe replied to bmacnaughton's topic in API & Templates
if ($fields->get('myfield')->type instanceof FieldtypeLanguageInterface) { // do something } 'myfield' can be the fieldname or field-id -
I cannot reproduce. No probleme to run setlocale() from config.php. This cannot cause such a problem. Did you use the same database for your fresh install? Or is the database still there? In case of complete crash access directly to the database via phpMyAdmin, adminer or any other mysql administration tool and export the database first as .sql or zipped sql file to have a backup. Do you have a tool like this in use? You can make also regularly backups of your database via cronjob: http://modules.processwire.com/modules/cronjob-database-backup/ File permissions checked? Really no backup of the uploaded files?
-
Displaying and restricting total files per template and children
kixe replied to Kiwi Chris's topic in Getting Started
@Kiwi Chris Sounds interesting! Take this small file information module as a first approach. Furthermore there is this related old and (unsupported?) module in the modules directory: http://modules.processwire.com/modules/manage-files/ Have fun with coding. <?php namespace ProcessWire; class AdminFileInfo extends WireData implements Module, ConfigurableModule { /** * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Admin File Info', 'summary' => __('Overview of all Pagefiles living under a specific branch'), 'href' => '', 'author' => 'kixe', 'version' => 100, 'icon' => 'files-o' ); } /** * Initialize, attach hooks * */ public function init() { } /** * create Info Table * */ static public function getInfoTable($parentID = 1) { $treePages = wire('pages')->find("has_parent=$parentID,include=all"); $table = wire('modules')->get('MarkupAdminDataTable'); $table->headerRow(array('PageID','Filename','size')); $table->totalSize = 0; // byte counter // @todo Notice: Undefined offset: 1 in /Users/c/Sites/_processwire/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module on line 276 foreach ($treePages as $singlePage) { if (PagefilesManager::hasFiles($singlePage) == false) continue; // no files $pageFileNames = $singlePage->filesManager->getFiles(); // get all files of this page foreach ($pageFileNames as $pageFileName) { if(null === $file = $singlePage->filesManager->getFile($pageFileName)) continue; // orphaned stuff $table->totalSize += $file->filesize; $table->row(array("#$singlePage->id" => $singlePage->editUrl, $pageFileName => $file->url, wireBytesStr($file->filesize))); } } return $table; } /** * module settings * */ static public function getModuleConfigInputfields(array $data) { $modules = wire('modules'); $parentID = isset($data['parent'])? $data['parent']: null; $fields = new InputfieldWrapper(); $f = $modules->get('InputfieldPageListSelect'); $f->attr('id+name', 'parent'); $f->attr('value', $parentID); $f->icon = 'tree'; $f->label = __('Page Tree Parent'); $f->description = __("Select a parent page and click submit to get information about all files under this tree."); $fields->add($f); if ($parentID) { $page = wire('pages')->get($parentID); $table = self::getInfoTable($parentID); $f = $modules->get('InputfieldMarkup'); $f->label = __('File Info for Page Branch: ').$page->path; $_description = __("This page branch uses %s of storage space for files."); $f->description = sprintf($_description, wireBytesStr($table->totalSize)); $f->value = $table->render(); $fields->add($f); } return $fields; } } -
Display custom content in otherwise empty FieldsetTab?
kixe replied to hellomoto's topic in General Support
One approach is to use InputfieldMarkup. I wrote a Fieldtype which displays any markup related to the field settings or template settings. Feel free to use it. You can easily include your stuff via iframe. Another approach is to hook in your tab. FieldtypeMarkup.zip -
@Petra Welcome to the forums. In such cases you have 2 handy friends in ProcessWire. https://modules.processwire.com/modules/process-jumplinks/ https://modules.processwire.com/modules/process-redirects/
-
Get the same 'set password' form on the front-end
kixe replied to modifiedcontent's topic in General Support
The nifty code: $base = wire('config')->urls; $cssUrl = $base->InputfieldPassword."InputfieldPassword.css"; echo '<link rel="stylesheet" href="'.$cssUrl.'">'; $jsUrls = array(); $jsUrls[] = $base->InputfieldPassword."complexify/jquery.complexify.min.js"; $jsUrls[] = $base->InputfieldPassword."complexify/jquery.complexify.banlist.js"; $jsUrls[] = $base->JqueryCore."xregexp.min.js"; $jsUrls[] = $base->InputfieldPassword."InputfieldPassword.min.js"; foreach ($jsUrls as $jsUrl) { echo "<script src='$jsUrl'></script>"; } -
Best approch for more and less important languages
kixe replied to dreerr's topic in Multi-Language Support
How to disable/ enable specified languages in language fields for specified pages. 1.) Put this in your config.php and define pages and related languages via IDs /** * enable specified languages for specified pages in the page edit interface * use keys (IDs) for the pages and arrays of language->ids which you want to enable for this page * */ $config->editablePageLanguages = array( 1 => array(1072), // only one other language beside default 1634 => array() // only default ); 2.) Add this hook to your ready.php $this->addHookBefore('ProcessPageEdit::execute', function($e) { // get id of page beeing edited $pid = (int) $this->input->get('id'); if (!$pid) return; $configPageLanguages = $this->wire('config')->editablePageLanguages; if (!array_key_exists($pid, $configPageLanguages)) return; foreach ($this->wire('languages') as $lang) { if ($lang->isDefault() || in_array($lang->id, $configPageLanguages[$pid])) continue; $lang = $this->wire('languages')->get($lang->id); $lang->status = 1024; } $this->wire('languages')->reloadLanguages(); }); With a few changes within the foreach loop, you can change from whitelisting to blacklisting if this is more appropriate to your needs. -
File upload error - SQLSTATE[23000]: Integrity constraint violation
kixe replied to Karl_T's topic in General Support
Normally there cannot be a duplication of the sort index for the same pages_id. Before an Imagefield is stored all page related entries (pages_id == $page->id) are deleted first from the database before the new sorted images are stored (@see /wire/core/FieldtypeMulti.php) .Try to clear manually all related entries from the database and try again. -
@derdogan In PW >= 3.0.39 you have the option to modify sql_mode via $config->dbSqlModes too. Have a look here: https://github.com/processwire/processwire/blob/master/wire/config.php#L879 Thanks @ryan to point this out.
-
Both is possible since InputfieldWrapper::get() calls InputfieldWrapper::getChildByName() /** * assuming $form is a member of InputfieldWrapper class * the return of the following api calls are similar * if the field exists the return value is an instance of Inputfield otherwise NULL */ $form->tags; $form->get('tags'); $form->getChildByName('tags');
-
ckeditor extra allowed content not work properly
kixe replied to adrianmak's topic in General Support
@adrianmak I didn't say you should put something inside another function. Did I? You can remove all the other stuff from the file, because it is not needed. What did you try to put inside your field? Please post here! The setting allows you to use exactly what I described. Nothing else! For example <i class="fa fa-awesome"></i> // allowed <i class="fa fa-awesome">nobreakspace-or-whatever</i> // NOT allowed -
ckeditor extra allowed content not work properly
kixe replied to adrianmak's topic in General Support
I agree, thats a bit tricky. There is a default setting in CKEditor which overrides the <i> tag with <em>. Luckily CKEditor is highly configurable, even in ProcessWire. If you don't want to disable ACF (Allowed Content Filtering) generally there is this specified solution: Create a config file: /site/modules/InputfieldCKEditor/config.js (if its not already there) with the following content to allow empty <i> tags as used for font-awesome icons CKEDITOR.config.protectedSource.push(/<i[a-z0-9\=\'\"_\- ]*><\/i>/g); -
ckeditor extra allowed content not work properly
kixe replied to adrianmak's topic in General Support
cool video 1000 words vs. 7 minutes video watching One picture says more than 1000 words Have a nice weekend -
@elabx Thanks for interest. Have a look here: https://processwire.com/talk/topic/1025-multisite/?do=findComment&comment=144509 https://github.com/kixe/Multisite/tree/kixe Need some thumbs up here https://github.com/processwire/processwire-requests/issues/94
-
I had similar problems after updating MYSQL via homebrew and importing a Backup made by ProcessDatabaseBackups. I could fix it by adding a few lines to my .sql file. Could you give some information about MYSQL version and your global settings (my.cnf) especially sql_mode? Try the following to solve # --- check sql mode SELECT @@sql_mode; +-------------------------------------------------------------------------------------------------------------------------------------------+ | @@sql_mode | +-------------------------------------------------------------------------------------------------------------------------------------------+ | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | +-------------------------------------------------------------------------------------------------------------------------------------------+ # --- you could add this on top in the .sql file # --- remove values STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE from the returned values and overwrite sql mode. Looks like SET @@session.sql_mode ="ONLY_FULL_GROUP_BYERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; # --- should also work SET @@session.sql_mode ="ALLOW_INVALID_DATES"; # --- or SET @@session.sql_mode ="";
-
The hook doesn't create a page. The hook is called if a page is created. If you add a page with a repeater field in its template the hook is called twice, because 2 pages have been created. If you have 2 repeater fields Pages::added will be triggered 3 times and so on. This is not a bug.
-
Unfortunately full language support doesn't works properly since the core function LanguageSupportPageNames::getPagePath() isn't hookable, whereas Page::path() is. I posted a request to change this. Support welcome. Thanks in advance. https://github.com/processwire/processwire-requests/issues/94
-
Forked this module a few days ago and ended up in a complete rewrite. Still under development and testing but working properly here. What is different? Do not worry about page naming. The root page is defined via ID. Full multilanguage support * take in account $template->slashUrl settings take in account LanguageSupportPagenames::useHomeSegment settings Fallback to default 404 page if custom 404 is not set Throws exception in case of misconfiguration Access of pages residing in a MultisitePageTree for other domains other than the corresponding root page is disallowed except for superuser Pages inside a MultisitePageTree accessible only via the modified url if called from the corresponding domain (throws 404 instead of unexpected redirects) Page paths are set via hook in Page::path() instead of modifying the return of Page::render() Crosslink support via the RTE (CK Editor) Link plugin Page view links in admin with correctly modified urls * under conditions: see next post! Feedback welcome. Have a try: https://github.com/kixe/Multisite/tree/kixe
-
@Kiwi Chris Welcome! Could this module be a solution for you? AdminRestrictBranch last update 12.04.2017, stable
-
@adrian I am working on a multisite project using single database. I forked multisite.module by Antti and another fork by Soma and started to adapt it for my needs. Luckily I found your module. I tried it out and it fits 90% to my needs and already saved a lot of work. Thanks for this great module. To get it working properly I need to make some changes. I think these changes could also be an enhancement of your module and you maybe want to take it. First of all I need an option to set branchRootParentId via hook which is currently not possible since the related function isn't hookable and private too. It would be nice if you could change the visibility of the function getBranchRootParentId() to protected and make it hookable. As far I can see there is no reason (security) to refrain from this. Furthermore there are 2 unexpected behaviours or potential issues: In Processwire the breadcrumb 'Pages' is prepended to breadcrumbs in the PageEdit area of the root page only. @see ProcessPageEdit::setupBreadcrumbs() This behaviour is different in your module. The breadcrumb is prepended in any Editor not only for the branchRootParent since $this->wire('breadcrumbs')->count() returns always 0. Is this wanted like that? I would prefer the default behavior here. I found a working solution. If you like I could post an issue on github. The BranchRootParent is not prepended to the Pagetree under PagesTab. ProcessPageList::executeNavJSON() doesn't prepend branchRootParent here. This couldn't be solved inside your module. I can see a PW issue here. ProcessPageList::executeNavJSON() should use $config->rootPageID instead of hardcoded 1 Possible Solution // in ProcessPageList::executeNavJSON // Line 489 from if(!$parentID) $parentID = 1; // to if(!$parentID) $parentID = $config->rootPageID; // Line 494 from if($parentID === 1 && $parentViewable) $items->prepend($parent); // to if($parentID === $config->rootPageID && $parentViewable) $items->prepend($parent); // Line 523 from $numChildren = $id > 1 ? $page->numChildren : 0; // to $numChildren = $id != $config->rootPageID ? $page->numChildren : 0; // Line 551 from if($page->id > 1 && $page->numChildren) { // to if($page->id != $config->rootPageID && $page->numChildren) { //in your module public function ready() { $this->wire('config')->rootPageID = $this->branchRootParentId; // ... }
-
@PWaddict Thanks. I could reproduce. I will try to fix this.
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
@PWaddict Just to be sure. You are talking about modules version 2.0.7 I pushed this morning? Note The strings you have posted doesn't work at all for me. I had to change from utf8 to utf-8 to get it work. But this depends on the environment and if you get the right output of your datetime field in the frontend it should work in the module too.
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with: