Jump to content

derelektrischemoench

Members
  • Content Count

    22
  • Joined

  • Last visited

Everything posted by derelektrischemoench

  1. HI guys, I'm using twig for my frontend and I'm trying to pass $options to the menu for rendering. For some reason I can't achieve what I want, as I seem unable to pass associative arrays to the render() call in twig. I'm using markupMenuBuilder to render the menu. I generate it as follows: $menuBuilder = $modules->get('MarkupMenuBuilder'); $options = array( 'has_children_class' => 'has_children', 'current_class' => 'active', 'menu_css_id' => 'main', 'menu_css_class' => 'nav', ); $view->set('options', $options); $view->set('menuBuilder', $menuBuilder); to make menuBuilder accept the options I would have to pass them to the render function in php like this: echo $menu->render('sidenav', $options) I can't get this to work in twig since I don't get how to pass the options to the render function when using twig. Can anyone point me in the right direction plz? Best whishes deM
  2. Hi guys, I'm trying to resize images which I query through getRandom(). I can't seem to get it right though. What I have so far is: $randomImage = $pages->get($targetPageId)->images->getRandom() Which returns an image, albeit in original resolution. I assumed I should be able to call resize() on the image like so: $randomImage = $pages->get($targetPageId)->images->getRandom()->width(400) Which unfortunately gives me an exception. I assume this is because getRandom() might not return an image but something else(?). So how would I do this correctly? Greetings derelektrischemoench
  3. Hi Kongondo, thanks for the quick reply; I fixed my mistake by nesting the loops. I'm totally not used to php, which treats arrays very differently than other languages. What I ended up with was this: foreach ($menuItems as $item) { $targetPageId = $item['pages_id']; $randomImage = $pages->get($targetPageId)->images->getRandom(); $menuItemsRendered[] = array( 'page_id'=>$item['pages_id'], 'title'=>$item['title'], 'url'=>$item['url'], 'image'=>$randomImage ); } which works perfectly fine. Thx for the support.
  4. Hi guys, I'm struggling a little getting a menu rendered here. After having build the menu I want to manipulate it; I want to add all menu items to an array, grab an image from each of the target pages in the menu and then render each menu item with some pictures from its target page. I tried using getMenuItems() for this but somehow it fails, I probably don't really get how to properly use it. Here's what I have so far: $menuBuilder = $modules->get('MarkupMenuBuilder'); $menu = 'mainNav'; $menuItems = $menuBuilder->getMenuItems($menu, 2, $options); $bundledMenuItems = array(); $menuItemsWithPictures = array(); //build an array that holds the random picture for each category in the menu foreach ($menuItems as $menuItem) { $targetPage = $pages->get($menuItem->id); $menuItemsWithPictures['title'] = $targetPage->title; $menuItemsWithPictures['pictures'] = $targetPage->get('images'); //this array is intentional, I want to do some slideshow thingy there array_push($bundledMenuItems, $menuItemsWithPictures); } $view->set('menuItems', $menuItems); $view->set('bundledMenuItems', $bundledMenuItems); ?> (This code is probably highly questionable, I'm not really proficient in php; love ProcessWire but despise php...., but what the hell.) I can't, however, seem to render all the items with their corresponding pictures in the frontend. I'm using twig as a template engine; this is what var_dump returns in the frontend: pages: array(4) { [0]=> array(2) { ["title"]=> string(4) "Home" ["pictures"]=> object(ProcessWire\Pageimages)#235 (2) { ["count"]=> int(1) ["items"]=> array(1) { ["steinlampe_2_grayscale.png"]=> string(26) "steinlampe_2_grayscale.png" } } } [1]=> array(2) { ["title"]=> string(5) "Admin" ["pictures"]=> NULL } [2]=> array(2) { ["title"]=> NULL ["pictures"]=> NULL } [3]=> array(2) { ["title"]=> string(5) "Pages" ["pictures"]=> NULL } } ... which aren't the pages that I declared in the menu with menuBuilder. I there something I'm missing here? My desired menustructure should be: illustrationen leuchten impressum ... Does anyone have an idea what I got wrong here? Best regards, derelektrischemoench
  5. Thanks, that did the trick! Greetings, derelektrischemoench
  6. HI guys, I'm currently building a site which displays a selection of processwire pages in one frontend page. My Page tree looks something like this: flavors: a b c ... flavors is the page that gets rendered a, b, c... are child pages of this page. All of these pages contain an image field although some images are high res the other are low res. I added a checkbox field to select whether the image is high / lowres and i want to render them conditionally based on this checkbox value. I have troubles separating these pages though as I seem to be unable to query whether the high res checkbox is set. I'm using the twig template engine to render the frontend. My page selection looks something like this: $available_flavors = $pages->get(1017)->children(); $available_flavors_high_res = $pages->get(1017)->children('is_high_res_image=1'); In my frontend I render the values like that: <div class="row"> {% for flavor in available_flavors_high_res %} <div class="col-sm d-flex flex-column"> <div class="shishaFlavor align-self-center" style="background-image: url('{{ flavor.shisha_flavor_image.url }}')"> </div> <h3>{{ flavor.title }}</h3> </div> {% endfor %} </div> <div class="row"> {% for flavor in available_flavors_low_res %} <div class="col-6 col-sm-4 col-md-3 col-lg-2 d-flex flex-column"> <div class="shishaFlavor align-self-center smallImage" style="background-image: url('{{ flavor.shisha_flavor_image.url }}')"> </div> <h5>{{ flavor.title }}</h5> </div> {% endfor %} </div> The check whether the the high_res value is set, however gets ignored. I assume this has to do something with the way I select the child pages in the PHP snipptet above. Could someone point me in the right direction on how to correctly separate the images with the high-res- flag from the ones without? I guess this would boil down to correctly selecting the boolean. Thanks in advance, derelektrischemoench
  7. AAAAAWWW YEEEEA!. Thx... Don't know why I didn't think about that possibility myself. I only tried google cache but something was borked there. Anyways, thanks again and good luck getting your website stuff going ;-) Greetings DeM
  8. Oh yea, one other thing..... I tried rendering truncated posts on my front page, which worked fine. When I click on "Show more" on the truncated posts, I would expect the module to show me the full post and render the comments section etc. Well.... the rendering of the comments etc. works but the post remains truncated, though. It also outputs the "show more" link but when I click that, nothing happens. I use the "blog post" template to show individual posts, but I was unable to find a function that shows me the post in full..... Back when your blog was online I remembered that there was an argument that could be passed to renderPosts; something like renderPosts(truncate=false) or something like that. I tried that but when I do so, php throws an error. What was the exact argument / the correct way to enable have a single post including comments rendered in full? Best wishes, DeM
  9. Phew, nice to hear that. I was beginning to worry whether the documentation would be gone forever. but in that case.... This project of mine doesn't have a schedule so I'm going to wait until you've got your documentation up and running again because w/o it I'm lost. I'm excited to see the new stuff you've got planned, so good luck on your coding, for now .... Greetings from Germany, DeM
  10. good evening gentlemen, so I have recently set up a Vagrant LAMP stack with the your Blog Module to, well, develop a blog. Unfortunately though, I seem to be unable to reach your website on which you so beautifully used to explain the ins and outs of the API to the module. Apparently the domain got deleted according to the notification on the site. So, is this a permanent state, did you stop the further development of the module or can we expect to see your site up and running again in a few days? I really liked the tutorials you offered there, since I don't know that much about web development and it offered a great starting point to get stuff going. Best wishes, DeM
  11. Hi Guys, I was wondering whether there is an option to change the language of the publishing date of each post and also the archives from English to German. So far though, I was unable to find a solution to this. Is this possible? To elaborate: I want individual posts and the archive to say : 2015 März rather than 2015 March I tried changing the locale in my header.inc but that didn't help. So is there a way to achieve this? Greetings from Germany derelektrischemoench
  12. Hi guys, thanks for the great tutorial, however, I get zero output. Which is unfortunate. I'm new to this whole thing and my php-skills are poor, but could this have to do something with the last line of the file, the template-include? // include site's main template which outputs everything include("./home.php"); It would be awesome if anyone could help me with this. By the way, what would be my main template? I thought there was no such thing, the only thing that's consistent in my pages are the includes of the header and footer. /edit: I managed to do the redirect etc., after the mail is sent my code displays a success message, unfortunately though, it doesn't send a mail. I've tried several of my email adresses as recipients, it just doesn't work. Checked my spam folders as well, no luck there. I'm developing locally on a WAMP stack, could this have something to do with that perhaps something about the configuration of my apache server? /edit2: when I inspect the output of the site I get the following line: <form action="./" method="post"> Do I need to specify a designated mail option in a separate php- script? or does the one Ryan posted already do its job? Best regards, Chris
  13. Hi guys, I've got a little problem here which I can't completely get my head wrapped around. So I've got a site which has links to several picture galleries and I want to set one image as a thumbnail to enter the gallery, which so far, isn't that big of a problem. Then, I'd like to place a caption for the gallery inside that div on top of the image to make it animatable. Now my first approach would have been to use the css "background-image" property for the background and then use regular markup for the captions and animate these. But unfortunately I can't use the api with css. I've tried inline styles but that didn't work, then the image covered the caption. Basically I'm looking for something like this: <div class="thumbnail"> <a href="..."> (Link to my gallery) <div class="flex-item6" style="background-image: (<?php echo $image=$page->images->get ("chrysanthemum_thumbnail.png")->url; ?>)"> <span class="overlay">stuff</span> </a> </div> I just sketched this up, I'm on the road and can't access my original code, but I hope you get the idea. When I tried this earlier, either the markup wasn't displayed or it showed under the image when I used position:relative in my css. So where did I mess up probably somwhere with all the brackets and stuff when calling the api...? And is there a solution to this without using inline-style? /edit: I tried implementing it via css, which worked but that ultimately means that I would have to store my thumbnails separately in some folder and can't access the via the backend Thx Greetz derelektrischemoench
  14. Thx. The critical link I was missing was the whole image- field thing. I read tons of other stuff while googling for a solution and all of them had the echo $page->images - code but only from the code I wondered how PW could find the path to those images. Of course by storing it in an image field on the site. Quite obvious, actually. Thanks again.
  15. Of course. That worked. Thank you so much, this saved me a whole lot of trouble. Greetings from Baden- Württemberg ;-)
  16. Hm okay. Like I said, I'm new to this whole thing @pwired: I uploaded the images I wanted to the page (basically I added an image field to the template and the dragged and dropped them in there). Then I did the <img src="<?php echo $image = $page->images->get("name=filename.png"); ?>"/> Unfortunately that didn't work. Where's my mistake? Thanks for pointing the thing with the image field out, though, somehow my brain seems to be clogged, I didn't even remotely consider this option :/ Greetz DeM
  17. This is what I need. I just need a link to an image that doesn't change its filename but probably its directory.Unfortunately, though, the above example doesn't work for me.
  18. Hi guys, I'm trying to call an image inside an <img>- Tag, to make the directory structure more versatile, making it unnecessary to always type the whole path to the image I'm relatively new to web development, php, Processwire and the likes so this might occur like a stupid question to you. But please, bear with me, I've spent the last hour on this and I'm starting to feel stupid. Currently I have a few images embedded like so: <img src="direct/path/to/image.png"></img> But this sucks. is there a way that I can achieve a link to a certain image, respectively its filename, id or similar like e.g. so:? <img src= <?echo "image.png" ?>> or instead of a filename an ID or something similar, so that if I change the path of the image resource, they still get embedded. The solution to this is probably very simple, but I'm fairly new to php and Processwire and I couldn't figure it out. Help would be much appreciated. Best regards DeM
  19. Good afternoon, fellas, sooo I installed the blog module, and it works totally fine, kicking ass and everything, I love it. I'm currently working on a site which is not a blog, but has a blog- subpage, which I got rolling. But what happens, or more like what do I do, if I want a second Subpage on my site which uses the blog - functionality? is there a way to achieve this? consider the following page tree: Home stuff -> regular content stuff2-> Blog 1 stuff3 -> Blog 2 .. and so on. so basically I would want two subpages on my site on which I would be able to publish blog posts independent from each other, which (in my opinion) would mean that I could tell the blog module at a certain point to publish a post on either one of these two pages. Help would be much appreciated. Best regards, DeM /edit: so I kinda had an idea for an approach to a solution to my problem, my thought was, that I could use two templates, which output blog posts by category, so basically I'm looking for a function which outputs posts with category "blog1" on the first page and in a second php script, one that outputs posts with category "blog2" on a separate page. so far though, I couldn't find anything about that in the documentation, I only found output filtered by post author, does the same apply to post category? //edit 2: I managed to do that, just had to change a few lines in one of the php files. Finally, everything works, and I have to admit, I am totally impressed. this module kicks ass in any way imaginable. Thank you so much Kongondo. Greetings from Germany, DeM
  20. Hi Kongondo, so I reviewed my css (it's not that much so far), and I didn't find the use of the class "active" or anything comparable that would mess this stuff up further down the cascade, but I guess that's not the problem here. If I inspect my code and select a child item from my menu, the script simply doesn't apply the class "active", meaning the output markup stays completely the same. This is the code that generates my menu so far: <?php $options = array( 'wrapper_list_type' => 'ul',//ul, ol, nav, div, etc. 'list_type' => 'li',//li, a, span, etc. 'menu_css_id' => 'nav',//a CSS ID for the menu 'menu_css_class' => 'drop',//a CSS Class for the menu 'submenu_css_class' => 'submenu',//CSS Class for sub-menus 'has_children_class' => 'menu_child',//CSS Class for any menu item that has children 'first_class'=>'menu_top',//CSS Class for the first item in 'last_class' => 'menu_bottom', 'current_class' => 'active', 'current_class_level' => 2,//how high up the ancestral tree to apply 'current_class' 'default_title' => 0,//0=show saved titles;1=show actual/current titles 'include_children' => 4,//show 'natural' MB non-native descendant items as part of navigation 'm_max_level' => 2,//how deep to fetch 'include_children' ); $menu = $modules->get("MarkupMenuBuilder"); //load the module echo $menu->render('nav', $options); ?> so from my understanding the line 'current_class' => 'active' should assign the class "active" to the currently selected/active menu item, which would then enable me to adress this class via css, correct? Unfortunately this class assignment doesn't take place Perhaps I got some of the code generating the menu wrong, I'm relatively new to programming and have yet to overcome sucking at it, so feel free to correct me Thx so far derelektrischemoench //edit: Solved it myself. The problem was that I didn't set my "home" page as the parent of the menu tree, I assumed current_class_level somehow magically recognized the site tree and applied .active to parent items. Which, of course, it didn't. Thx nevertheless, sry for wasting time by being stupid
  21. Hi guys, I have a similar / the same problem as Torsten. But somehow, if I set "current_class_level" to 2, it doesn't seem to apply, for reasons I don't understand. My site structure looks something like this Home about used stuff products Tv Home Cinema Speakers Streaming solutions etc. If I navigate to products, the script automatically assigns the css-class "active" to the selected menu item, which changes the color of the menu item in the navbar. If I navigate to one of the children of "products" (TV,Home cinema etc.) though, my top menu item "products" loses its css class. I thought I could prevent "products" from losing its css- class when browsing children of "products" by increasing the value of 'current_class_level' to something greater than 1. But if I do so, it doesn't change anything, my menu item "products" still loses its class when I navigate to one of its children. I hope my description was understandable, and I hope even more that someone has a solution for my problem. Best regards, derelektrischemoench
×
×
  • Create New...