Jump to content

Juergen

Members
  • Posts

    1,392
  • Joined

  • Last visited

  • Days Won

    17

Everything posted by Juergen

  1. Only to mention: Using $page->children() will also show all pages independent of release status.
  2. Hello @LostKobrakai I have written a class for creating tables. The first class is the table class itself. The second class is a class for creating table-cells (the content of the table of course). Both class extends from the same parent class (a wrapper class). So both use the same methods from the wrapper class (in this case methods for setting attributes like class, id,...) My aim was to chain methods from the table-cell class inside the table class. My OOP-code of creating a table looks like this in this case: $table = ( new \UikitClass\Table(3))->setCaption('Beschreibung'); //thead $table->addHeaderCell()->setModifier('expand')->setText('Spalte 1')->setClass('thclass'); $table->addHeaderCell()->setText('Spalte 2')->setClass('custom'); $table->addHeaderCell()->setText('Spalte 3')->setClass('custom'); //tbody $table->addCell()->setText('Text 1'); $table->addCell()->setText('Text 1')->setClass('custom'); $table->addCell()->setText('Text 1')->setClass('custom'); $table->addCell()->setText('Text 1')->setClass('custom'); $table->addCell()->setText('')->setClass('custom'); //tfoot $table->addFooterCell()->setText('Footer')->setClass('uk-text-center')->setAttribute(['colspan' => '3']); echo $table->render(); So every chaining starts from $table for easier writing. Therefore I wanted to include the class of the table-cells inside the table class. In this case addHeaderCell(), addCell() and addFooterCell holding an object of the table-cell class and all methods after this affect the table-cell object. So I start with $table (table-class object), switch to the table-cell object (fe addHeaderCell() method), use methods to the table-cell object and add this to the table class. Maybe a little bit difficult to explain, but the idea behind was to make writing easier for the developer.
  3. Thanks @Edison so I was very close to the solution ?. This works !! Have a nice weekend too!
  4. Hello @all, I know how to use chaining with pipe within one class, but I want to know if it is possible to use chaining of methods of 2 different classes. Here is a simple code example: class A() { protected $text = ''; public function setText(string $value = null) { $this->text = trim($value); return $this; } } class B() { public function addText() { //instantiate class A return new class A(); return $this; ?????????? } } Use it: $test = new B(); $test->addText->setText(); addText is method of class A setText is method of class B As you can see there are 2 different classes (A and B). A has the method setText() and B has the method addText(). My goal is to create a new instance of class B, then I want to use the method addText(), which is a method of class B and this method should instantiate an object of class A. After that I want to go on with methods of class A in the chaining. So it will be a mix of class A and B. Is this possible? I have tried to find useful information via Google but without success. Can someone give me a hint, how this can be implemented. Thanks for your help!
  5. Here is another snippet that I use to get rid of unwanted table properties: // Remove unwanted attributes from tables CKEDITOR.on('dialogDefinition', function(ev) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; if (dialogName == 'table') { var info = dialogDefinition.getContents('info'); info.remove('txtWidth'); info.remove('txtHeight'); info.remove('txtBorder'); info.remove('txtCellPad'); info.remove('txtSummary'); info.remove('txtCellSpace'); info.remove('cmbAlign'); var advanced = dialogDefinition.getContents('advanced'); advanced.remove('advStyles'); advanced.remove('advId'); //Id attribute advanced.remove('advLangDir'); // writing direction advanced.get('advCSSClasses')['default'] = 'uk-table'; //set default class for table } Put this code inside your custom config.js Best regards
  6. I have opened a new issue on Github: https://github.com/processwire/processwire-issues/issues/929
  7. Thanks for this!! I think this is one thing that is much more important today because you have to add image credits to the site. So this should be part of the core.
  8. Now this works: $module = wire('modules')->getModule('ProcessPageAdd'); $test = ($module->executeNavJSON()); return $test; This gives me the following json-output: {"url":"\/processwire\/processwire\/page\/add\/","label":"Modules","icon":"plus-circle","add":null,"list":[{"url":"?parent_id=1016&template_id=57","label":"Eine neue Leistung erstellen","icon":"plus-circle","parent_id":1016,"template_id":57},{"url":"?parent_id=1048&template_id=51","label":"Neuigkeit erstellen","icon":"plus-circle","parent_id":1048,"template_id":51},{"url":"bookmarks\/?role=0","label":"Lesezeichen","icon":"bookmark-o","className":"separator separator"}]} And these are the pages I was looking for: list":[ {"url":"?parent_id=1016&template_id=57","label":"Eine neue Leistung erstellen","icon":"plus-circle","parent_id":1016,"template_id":57},/n{"url":"?parent_id=1048&template_id=51","label":"Neuigkeit erstellen","icon":"plus-circle","parent_id":1048,"template_id":51}........ So I get: parent_id: 1016, template_id:57 and parent_id:1048, template_id:51 These are the 2 pages that I have in the shortcut menu and the IDs that I need? So for the moment my new dashboard has the same functionality as the add-new navigation of PW, but a little more userfriendly than the small navigation in the left corner. New shortcut items can be added via the bookmark button, so every user can add his own favorites shortcuts to make his dashboard individually (if he has the rights of course ;-).
  9. Really complicated, but I will give this a try. I thought that it must be really simple to get the IDs of the pages in the shortcut navigation, but it isnt. Thanks for the tipp!!!
  10. Yes the folder is under site and if I look into the source code I can see that the correct config.js is there. "stylesSet": "customstyles:/processwire/site/templates/scripts/customstyles.js?nc=1563189734", "customConfig": "/processwire/site/modules/InputfieldCKEditor/config-body.js?nc=1563175984" Inside the config-body.js I have the following code: CKEDITOR.editorConfig = function( config ) { config.contentsCss = 'https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.6/css/uikit.min.css'; }; But the CSS from the CDN will not be loaded. Instead the one from the wire-folder will be loaded. "baseHref": "/processwire/", "contentsCss": "/processwire/wire/modules/Inputfield/InputfieldCKEditor/contents.css", "extraPlugins": "pwimage,pwlink,sourcedialog", ?
  11. Same result, but I have checked the database (table 'modules') and the data column is empty. So I am wondering where the shortcuts pages are stored? Inside the module file of this module you can find following lines: $configData = $this->wire('modules')->getModuleConfigData($this); // because admin theme calls with noInit option $shortcutSort = isset($configData['shortcutSort']) ? $configData['shortcutSort'] : array(); So there must be an index 'shortcutSort' inside the configuration array. Very strange?!?
  12. Hello, I have tried to get the config data of the ProcessPageAdd module because I need the pages which are inside the ASM-Select for the 'Add new' shortcuts. This is what I have tried according to the docs: $data = wire('modules')->getConfig('ProcessPageAdd'); print_r($data); But the only output I get is 1(true). Is there something I am missing or is this the wrong way? Maybe someone can help me out. Thanks
  13. Thanks @dragan I use a custom style set for special UIKit markup classes. Including the code inside this file does not work too. BTW this file should be used to add custom styles to the dropdown not for configuration of the stylesheets. The docs of PW says that the configuration changes should be written inside /site/modules/InputfieldCKEditor/config.js I have tried it but without success. ?
  14. Hello @ all, I am struggeling to add multiple stylesheets to the CKEditor content area. Docs from CKEditor says that it is possible to add a string or an array as source for the stylesheets. Inside the CKEditor settings tab there is an input field where you can add a path to a custom stylesheet. This works only if I enter only one stylesheet (string) - if i try to enter an array it fails and falls back to the default stylesheet. Therefore I have tried to add the stylesheets to the config-body.js directly (because the field is called body) CKEDITOR.editorConfig = function( config ) { config.contentsCss = ['https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.6/css/uikit.min.css', '/site/modules/InputfieldCKEditor/admin.css']; }; But this does not work either. Has someone an idea to get it working? Best regards
  15. That will be great ?! Thanks for you contribution @MoritzLost
  16. Thanks @teppo this is a very clear explanation. Chaining is only possible with a reference to the object itself not with a string. You are right: my method for text is a combination of a setter an a getter and the getter will always return a string or null, so no reference to the object itself. So I ended up separating getter and setter into 2 different methods and now it works with or without chaining: public function setText(string $value = null) { $this->text = trim($value); return $this; } public function getText() { return $this->text; } In other forums they also do not recommend to combine getter and setter in one method. I thought that combining both would be an useful and elegant way - so I have learnt something new ?! Thanks! It helps me a lot!!
  17. Hello @ all, I am learning OOP and I have a problem for which i didnt find a solution in the web. Maybe someone can help me out. I have written a class to render alerts. Fe. to output an alert box I can write: default notation: $alert = new Alert(); $alert->text('This is the alert text'); echo $alert->render(); or with method chaining: echo (new Alert())->text('This is the alert text')->render(); Both methods work until text has content inside. So sometimes there is no text content present (text value is empty). default notation (this works): $alert = new Alert(); $alert->text(); echo $alert->render(); or with method chaining (this leads to an error): echo (new Alert())->text()->render(); So if text has no value I get this error if I use method chaining: Call to member function render on null This is the getter/setter method for the text public function text(string $value = null) { if($value){ $this->text = trim($value); return $this; } else { return $this->text; } } Is there a way to get method chaining to work if there is no value in the text property present? Thanks for your help
  18. Thank you @Wanze, I have tried this before, but without luck. Now I see what went wrong - I haven´t used camelcase (noindex instead of noIndex) - silly mistake ?
  19. Hi, I am struggeling with a problem to set the robots metatags (noIndex, noFollow) within a before page save hook. Here is my code (inside ready.php): $pages->addHookBefore('save', function($event) { $page = $event->arguments('page'); if($page->template == 'privacy-policy' || $page->template == 'search' || $page->template == 'error') { //SEO Maestro $page->seo->sitemap->include = 0; $page->seo->sitemap->priority = ''; //How to set robots to no index and no follow //??????????? } }); I could not figure out a way to accomplish this. Can anyone help me out? Thanks
  20. Thank you @Wanze for the additions (especially for the structured data)!!
  21. I wanted to create a HTML Sitemap with the same pages as the XML sitemap. Unfortunately the $pages->find() method doesn´t support the order of the page tree, so I could not use the provided function to get all pages from the XML-Sitemap in the same order as the page tree. $pages->find('seo.sitemap_include=1'); So I wrote a little recursive function to render all the pages except the ones which were not included in the XML sitemap. The pages have the same order as in the page tree. function renderSitemap($items, $depth = 0) { $separator = ''; for ($x = 0; $x <= $depth; $x++) { $separator .= '-'; } foreach ($items as $item) { if ($item->seo->sitemap->include == 1) { $subitems = $item->children(); if (count($subitems)>0) { echo '<b>'.$separator.$item->title . '</b><br />'; } else { echo $separator.$item->title . '<br />'; } $subitems = $item->children(); renderSitemap($subitems, $depth+1); } } } //OUTPUT INSIDE TEMPLATE FILE $items = $pages->get("/")->children(); echo '-'.$pages->get("/")->title.'<br />';//this is only for the homepage renderSitemap($items); This little function is not intended as a complete HTML sitemap markup generation solution. It only outputs the title of the pages (without links). It should only be a starting point for others to show you how to use SEOMaestro settings in combination with a frontend sitemap. Maybe if someone has a better solution it would be great if you post it here. Best regards This is what it looks like:
  22. Hello @Peter Knight I think that there is no render tag method for the robot tags, but you can use the following: $page->seo->robots->data['noIndex'] $page->seo->robots->data['noFollow'] This returns true if 'no index' was choosen and true if 'no follow' was choosen. Create the meta tags by yourself and use PHP to fill in these values into the meta tags. Best regards Jürgen
  23. I have not installed this module and I have the same problem. On my current installation I have only installed a few modules. So I guess it has nothing to do with other modules.
  24. Thank you @Wanze for this great module. Only one thing to mention: From the point of security it is not recommended to add the generator metatag (or any other information to help hackers to know something about the system). So it would be great to add a setting checkbox to disable the rendering of this metatag. I know I can render each metatag separately but using your render method ($page->seo->render()) would be much more comfortable ?. Best regards Jürgen
  25. If I understand you correctly, you have added a new image field to your template for the featured image and you need the url for the src attribute. ? Lets assume the name of the new image field is 'featured_image' you will get the url of this image by using $page->featured_image->url So the code of the blog-post.php could look like this: <?php $img = $page->featured_image; if($img) { $img = $img->width(600); echo "<p class='uk-text-center'><img src='$img->url' alt='$img->description'></p>"; } ?> Image is an object, so you have to grab the different values (attributes) of the image by using the arrows (->) followed by the name of the attribute (size, url,...). You will find more information about getting image values here If this was not the information you are asking for please post your code for better understanding. Best regards
×
×
  • Create New...