Jump to content

dotnetic

Members
  • Posts

    862
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by dotnetic

  1. There is a hook Pages::cloned $this->addHookAfter('Pages::cloned', $this, 'pageCloned') and you can interact with the cloned page: /** * @param HookEvent $event * Method to change the status of a cloned page */ public function pageCloned(HookEvent $event) { // $return = $event->return; $page = $event->arguments(0); $clone = $event->arguments(1); $clone->of(false); $clone->modified = date("Y-m-d H:i:s"); $clone->created_users_id = $this->user->id; $clone->save(array('quiet' => true)); }
  2. Really nicely designed website. I like it!
  3. Please open the dev tools of your browser and take a look if there are errors in the console or if there are 404 errors in the network panel. I think that the paths might be wrong. In dev tools network tab you will see from where the browser tries to load the assets. Also the rel="stylesheet" in your script tag absolutely makes no sense, please remove it.
  4. I just released the latest version with some fixes from @bernhard. Thanks for the corrections. I also updated the dev branch with latest translations to the core 3.0.180. Enjoy
  5. In your post you wrote two different directories. First you mention an "img" folder, then you try to acces the "imgs" folder. Please check that you are using the correct path.
  6. This is the normal way of rendering output, but as with almost everything in ProcessWire it is up to you. For example you could use your own render logic via _init.php without the need for any other .php file. Or you could integrate a template language like Twig or Smarty via Template Engine Factory.
  7. As I mentioned you have to check if the correct locale is installed first. Because if you set it in ProcessWires "C" setting to it_IT or it_IT@euro and the locale is not installed, then you don't get the localized dates. And I forgot that you have to use strftime to get a localized date. You can find a description later in this post. The easiest way to check what locales are installed is to run `locales -a` if you have shell access (SSH for example). If this is not possible, then you have to modify my script from the first post and insert different values for italian there. <?php echo '<h1>test for locales</h1>'; /* try different possible locale names for italian GB as of PHP 4.3.0 */ echo '<p>'; $loc_it = setlocale(LC_ALL, 'it_IT', 'it_IT@euro', 'it_IT.UTF-8'); echo "Preferred locale for italian on this system is '$loc_it'"; echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978)); function smarty_modifier_number_format( $string, $decimals = 2 ) { $locale = localeconv(); // setlocale( LC_NUMERIC, null ); $string = str_replace(',', '.', $string); $thousand_separator = ( $locale['thousands_sep'] == '' ) ? '.' : $locale['thousands_sep']; $decimal_separator = $locale['decimal_point']; return @utf8_encode(number_format( $string, $decimals, $decimal_separator, $thousand_separator )); } echo "<br>"; echo smarty_modifier_number_format('12,90 g'); If you run it then, and the preferred locale is not an italian one, then an italian locale might be missing on the system and you have to tell your host to install it, if that is possible. When switching languages, you have to set the locale for example in your _init.php setlocale(LC_ALL, 'it_IT', 'it_IT.UTF-8', 'it_IT@euro'); and then to get a localized date you have to use the strftime function or ProcessWire's date method (which can be formatted using strftime) for output. If the italian locale is missing, you could use a custom PHP function that returns dates in your language.
  8. You have to set and use the correct locale for italian. Please read this post and set the C setting to "it_IT" or the locale that you found with the script from the first post. How to do it is written in the comment "Warning about Server Locale after update from 3.0.52 > 3.0.53 - Help! - Page 2 - General Support - ProcessWire Support Forums" .
  9. Thanks for your continued development on this. I still need to have a look at it.
  10. You found the solution just 4 years after posting this thread?! Wow. That's fast 😉
  11. The problem is, that you forgot to insert the {class} placeholder in the itemMarkup option which inserts the active class to the active element. It has to look like this <li class='page-item {class}'>{out}</li> so that the active class can be added.
  12. Thank you @Pete for your work on the forum.
  13. Open your dev tools and inspect the active element. Which CSS classes does it have? If it doesn't have "page-item active" then something is wrong. If it has these classes, then maybe you need to use some different code for the bootstrap styling. Maybe provide the HTML code, that is outputted in dev tools, so we can help you more
  14. @Mike-it could you add an issue to github, if it does not exist yet?
  15. Wow. This looks so cool. The creation of fields and templates via the admin might not be for everyone, but I think you can generate the migration file also by hand, right? A feature that has been requested multiple time, is that all changes that you do in the admin should be tracked and added to a migration. I like the basic idea behind it, and think of a hook, that gets triggered after creating a field/template, or making modifications to a field, which automatically or after confirmation modifies or adds a migration file. As you are also running a diff, you might create a migration automatically, to see what changes have been made to templates/fields/contents since the last migration. Then you would just choose which templates/fields/contents should be included in the migration. For example you added a new field, added it to two templates and created a new page with one of the templates. Now your module could run a "Get changes" command, that fetches all differences since the migration and asks which of them you want to integrate. With this behaviour you would not have to remember and "define the affected elements" as in your video. What you think about this approach? I am also happy to have a look at your code and try it out, because I think migrations is a major issue with ProcessWire right now. I am using @bernhards RockMigration atm, but also like your approach. Migrations should be an important part of the core IMHO.
  16. Thanks @bernhard. Problem solved
  17. I added this example code taken from ProcessWire 3.0.173 core updates: New URL hooks to my site/_init.php // _init.php wire()->addHook('/hello/world', function($event) { return 'Hello World'; }); and get the following error: So what is wrong? As I am in the _init.php the hook should be attached during init, right?
  18. @dlen I forgot, that the name of the default language is always default and can not be changed. Please try this updated code. BTW: where did you took that code example from? <?php $alternate_languages = ''; foreach ($languages as $language) { // if this page is not viewable in the language, skip it if (!$page->viewable($language)) { continue; } // get the http URL for this page in the given language $url = $page->localHttpUrl($language); // output the <link> tag: note that this assumes your language names are the same as required by hreflang. if ($language->name === 'default') { $alternate_languages .= "\n\t<link rel='alternate' hreflang='x-default' href='$url' />"; } else{ $alternate_languages .= "\n\t<link rel='alternate' hreflang='{$language->name}' href='$url' />"; } } echo $alternate_languages; ?>
  19. Please check if the name of your german language is really "de", if not, please add it. I am not talking about the de name of the homepage, but the name of the language
  20. Please show us the code that you use to generate the hreflang output.
  21. Hey, sure, as I find the time. But could you please create an issue on github, so it is easier for me to track. PR's are also always welcome.
  22. I am looking for an output strategy for repater fields or Repater Matrix fields (Pro fields) in my case. I would like to replicate the approach Ryan described in the blog post https://processwire.com/blog/posts/more-repeaters-repeater-matrix-and-new-field-rendering/ , but using Template Engine Factory (because I want to use Smarty or another template language). In short: Instead of a foreach loop that then uses many if clauses to distinguish the type, I would like to have a separate controller and template for each repeater matrix item. The controller should be used to modify the output before. Here is my working code, but I wonder if it might be better to use hooks like Template Engine Factory's hookBeforePageRender, or something else? //_init.php $factory = $this->modules->get('TemplateEngineFactory'); // check if the actual page has a modules_repeater (Repeater Matrix field) // and provide the output of the different modules as a variable if ($this->page->hasField('modules_repeater')) { // now get the output based on the type foreach ($this->page->modules_repeater as $module) { // Get the controller, to render a repeater item. $controller = $factory->controller("modules_controllers/{$module->type}.php", "modules/{$module->type}.tpl"); // You might pass some data via to the controller file, which you find at site/templates/modules_controller/nameOfTheRepeaterMatrixItem. // We assign the module repeater item to the $page variable so we can use it in our template and controller like this // $page->hero_headline $controller->page = $module; $controller->execute(); $output = $factory->render("modules/{$module->type}", ['page' => $module]); // Executing the controller renders the associated template via template engine. $this->view->set('modules_repeater', $output); } } Any suggestions?
  23. @bernhard Is there a way to generate and insert content into a repeater matrix item via RockMigrations? First I generate the fields needed for the repeater matrix and add the repeater matrix field to a page. Then I want to create a new hero item on that page and insert some contents in it.
  24. I try to setup a repeater matrix field. Can anybody like @aComAdi provide a working example, how to do this? EDIT: It turned out, that I needed version 5 of the RepeaterMatrix field.
×
×
  • Create New...