Jump to content

pwired

Members
  • Posts

    2,318
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by pwired

  1. Maybe this can be helpful ========================================================================================= $page->images->first(); // first image $page->images->last(); // last image $page->images->eq(0); // first image $page->images->eq(1); // second image ========================================================================================= Find the total number of pictures // Get the page that holds the the pictures $p = $pages->get('/path_to_page/'); $numberofimages = $p->images->count(); echo $numberofimages; ========================================================================================= images is an array ... see all the array elements inside the array images 1) Get a Page who has images $p = $pages->get('/path_to_page/'); 2) this gets all the elements $array = $p->images->getKeys(); 3) and this outputs to see them echo implode($array); ========================================================================================= Because an array starts with item number 0 and not 1 ... the last item number in the array is one less than total counted // echo $n; show the total counted number // echo $n--; show the total counted number minus 1 ... this is the last item in the array Note that when you upload an image in the backend by default it will be the LAST one added If you want to output the images in a gallery on the front and want the latest uploaded image to be the first in the gallery, you have to reverse the backend image order: Example: $var_page = $pages->get('/path_to_your_page/'); foreach($var_page->images->reverse() as $image) { echo "<a href='$image->link'><img src='$image->url' alt='description' width='' height=''></a>"; } ========================================================================================= F.
  2. Check this one out: Processwire on the web with wirekit - - - https://bestofphp.com/repo/kreativan-wirekit-core https://github.com/kreativan/wirekit-core https://start.wirekit.dev/core/wirekit/ui/
  3. Coding Ajax directly in Processwire can be tricky. I always set my Ajax first up locally in plane html/php and when I have it working there, then I port it over to Processwire. Works for me.
  4. You can use the template name (both external and internal template) to choose any layout for any webpage or any part of the website I have the layouts stored in a view and an include folder and select them with php logic either on the template file or the view file This layout strategy is already in the forum posts for many years Here is an example: <?php namespace ProcessWire; // you can add here any business logic if needed to override default settings, values and $variables // default <head> include ($includes_path . "head.php"); // <head> is not a view such as the <header> <main> or <footer> - it is the <head> section of a website // default view <header> include ($views_path . "header.php"); // the <body> tag and the first <header> tag after the <body> tag // selected view <main> include ($views_path . "{$page->template->name}" . ".php"); // the main content view selected with the page template name (internal or external template file name) // default view <footer> include ($views_path . "footer.php");
  5. What about open web analytics .......... https://www.openwebanalytics.com/
  6. Thanks @Jan Romero for showing the correct way in this case: $p->images->get("videocounter=270")->url; I am aware now that I have to dive deeper into the processwire api with the use of arrays, Pageobjects and selectors ...
  7. Hi, In a page I want to find an image that has a specific field with a specific value In this case the Page = $p and the image that I am looking for has a field = videocounter and the value of this field = 270 I can find the image like this: $image = $p->images->find("videocounter=270"); so far so good But when I want to show the picture on the front: <img src="<?php echo $image->url ; ?>" /> It doesn't work, the image does not show With a few simple echos of $image; and $image->url; I found a work around that makes the image show up: <img src="<?php echo $image->url . $image; ?>" /> But I find this an ugly work around What would be the correct way to make the image show up ?
  8. not intended to start a fight ... but here are my pro's for using uikit ... It's called controlled bias ??
  9. Processwire is a headless cms/cmf and as such it only delivers your backend to the frontend in anyway you want with 0 limitations. That is what makes Processwire so great. Choose any cms framework you want but I really recommend not to start with big ones like bootstrap - uikit - etc. I recommend to start with pocketgrid css because it is perfect to first get familiar with using the processwire api outputting backend data on the front. https://arnaudleray.github.io/pocketgrid/ https://arnaudleray.github.io/pocketgrid/docs/ Once familiar with the Processwire api you can choose any cms framework you like. Bulma css is a great choice also ... flex based and all css ... no preinstalled JS, modular components (only use what you need) https://bulma.io/documentation/overview/start/
  10. Ah yes I forgot about make use of the config.php (or init.php) ..... thanks for pointing me there, will try that too. The paths that I declared in the _init.php ..... I simply declared them again on top of my hanna php code and now my hanna code is working in my ckeditor field So either way what will work I mark the question as solved. Note - did you guys know you can render a hanna code directly in a template like this: $hanna = $modules->get('TextformatterHannaCode'); echo $hanna->render("[[my_hanna_snippet]]"); https://processwire.com/talk/topic/14141-outputting-a-hanna-code-via-the-api-in-a-template/ Hanna Code is actually a powerful option.
  11. Hello Jan Thanks for replying on this. Instead of declaring my own file and url paths, using Processwire's api $config->paths hopefully will make it work I will try it and post back about it
  12. Hi, I am using a hanna code in a ckeditor field [[timeline]] In the _init.php I have declared $home_sidebar_timeline = $includes_path . "home_sidebar_timeline.php"; Can I use variables declared in the _init.php in a hanna code ? I have this php code in my hanna code: <?php include $home_sidebar_timeline; ?> When I put the hanna code [[timeline]] in a ckeditor field it doesn't work. How can I use a variable declared in the _init.php in a hanna code Do I need to use global variables ?
  13. Not sure what you mean by pattern ... I think it needs an extra pair of surrounding Parentheses ... if($page->hasChildren())
  14. Hi@Jan Romero, Thanks for pointing me back to the Details tab. Yes, now I have Ryan's suggestion working: you might want to disable the description and/or tags fields for the image, just for a more consistent appearance of inputs (though it's not required). The consistent appearance shows up and I simply use the Title instead of Description. How I ended up with this matter ? I was trying to add links to my images with <a> .... </a> and going through the forum posts first the module ImageExtra came up. Then I was reading a post of Jonathan Lahijani about the ability to have custom fields for images. All good now.
  15. Hi, I am setting up custom fields support for file and image fields as described here: https://processwire.com/blog/posts/pw-3.0.142/ I am using a Field with name: images and type: images All works well except for one thing. In the blog post it says: on the Input tab, set the Number of rows for description field to 0 (zero). When I go to my images field ... Setup > Fields > images and then go to the Input tab, there are a lot of settings there but I cannot find anything that says Number of rows for description field as mentioned in the blog post Anyone has an idea why that might be ?
  16. Thought that I was the only one trying to avoid composer. Thanks for posting this working solution (added to my snippets)
  17. Yes that makes sense. But in case of a multi language website how would you manage the text in the footer and the text on banners and banner slides, etc. ?
  18. Thanks for mentioning about version control ... haven't considered that one ... perhaps for bigger projects.
  19. Who is still hard coding graphics like a logo, banner, etc in sub folders like logo or banner in the styles folder ? I stopped working that way and create "Pages" in the back end such as a logo "Page" and a banner "Page" That way a logo and a banner etc. can be managed directly through the back end and no longer need a third party FTP tool. Makes it also more easy for the website user/client.
  20. From my perspective as a developer integrating CKEditor 5 into ProcessWire ... Seems to be the only perspective ...
  21. I remember it was. Lostkobrakai posted about this with solutions. I dont have any links at the moment but will post them later on.
  22. <div class="..."> <a n:foreach="$languages as $lang" href="{$page->localUrl($lang)}" class="..." > {$lang->title} </a> </div> Useful example and good jump start for me to try latte thanks for posting
  23. To make all the html layout better readable will make the workflow more productive I assume latte will allow me to rewrite php includes like this: <div class="header_navigation block"> <div class="header_language block">{language}</div> <div class="header_navbuttons block">{navbuttons}</div> </div>
  24. On the latte website I am reading some interesting things: - You don't have to look in the documentation. You don't have to learn another language. You just write like in PHP. - Latte is a next generation templating system – it understands HTML. Where other systems see only a bunch of characters, Latte sees HTML elements. - Latte is based on PHP, whereas Twig is based on Python. A designer in Latte doesn't have to constantly switch between two different conventions. I am using placeholders in my html using php and I must say it works really good and fast like this: <div class="header_navigation block"> <div class="header_language block"><?php include $header_language; ?></div> <div class="header_navbuttons block"><?php include $header_navbuttons; ?></div> </div> Here is my question: Could you say from your own experience if using latte shortcodes make more productive and is the overhead worth it ?
  25. Is it really necessary to have CKEditor 5 in Processwire ? Is CKEditor 4.x not more than safe and powerful enough already ? CKEditor 5 will not make more productive neither make a website client more happy. It will only make things more bloated. At least leave the option with the user and client to choose CKEditor 4.x or another simple Editor for the client. Most clients are non-tech people occupied with business for whom something like CKEditor 4.x is already complicated. They will never use all its options anyway. All they need is to change some prices, text and pictures. So please leave the option for the client to choose a simple Editor. What made Processwire stand out from the crowd was its focus on a versatile and powerful api with a core free from bloat. How much of that is still true ?
×
×
  • Create New...