Jump to content

jeremie

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by jeremie

  1. Hi, first I want to say i'm an hobbyist, not a professionnal developer. I've somehow managed to make a site-profile that I'm more or less happy with. It consists in a homepage, a projects resume page and project pages. So 3 templates. I've install tracy console but realize that my knowledge stops there. I'm looking for someone familiar with processwire and tracy debugger to help me arrange and optimize my site. I'm not in any kind of rush and have some money dedicated to this. my best, je
  2. thanks ttttim, I had corrected the js error but I was missing the display tag in for .column. I really appreciate It was giving me so much headache.
  3. Hi, I'm trying to filter my projects by typologies which are a page reference field in my project page. I'm using w3.css and I started from this example https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_filter_elements in my grid template I have this <div id="myBtnContainer" class="w3-padding-16"> <button class="btn active" onclick="filterSelection('all')"> All</button> <?php $typos = $pages->find("template=types"); foreach ($typos as $typo){ echo "<button class='btn' onclick={filterSelection('$typo->name')}>$typo->title</button>"; } ?> </div> <div class="w3-row"> <?php $items = $pages->find("template=project"); foreach ($items as $item){ $typotag = $item->Types->name; $thumb = $item->images->first()->size(400,300); echo "<div class='column $typotag'> <div class='w3-card-4 jegreen'> <a href='$item->url'> <img src='$thumb->url' alt='Too Bad' style='width:100%'> <div class='w3-container'> <h5>$item->title</h5> </div> </a> </div> </div>"; } ?> </div> my script looks like this filterSelection("all")// Execute the function and show all columns function filterSelection(c) { var x, i; x = document.getElementsByClassName("column"); if (c == "all") c = ""; // Add the "show" class (display:block) to the filtered elements, and remove the "show" class from the elements that are not selected for (i = 0; i < x.length; i++) { w3RemoveClass(x[i], "w3-show"); if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "w3-show"); } } // Show filtered elements function w3AddClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { if (arr1.indexOf(arr2[i]) == -1) { element.className += " " + arr2[i]; } } } // Hide elements that are not selected function w3RemoveClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { while (arr1.indexOf(arr2[i]) > -1) { arr1.splice(arr1.indexOf(arr2[i]), 1); } } element.className = arr1.join(" "); } // Add active class to the current button (highlight it) var btnContainer = document.getElementById("myBtnContainer"); var btns = btnContainer.getElementsByClassName("btn"); for (var i = 0; i < btns.length; i++) { btns[i].addEventListener("click", function(){ var current = document.getElementsByClassName("active"); current[0].className = current[0].className.replace(" active", ""); this.className += " active"; }); } and I add this to my css .show { display: block; } .filterDiv { float: left; background-color: #c8d7d4; color: #ffffff; width: 100px; line-height: 100px; text-align: center; margin: 2px; display: none; } .container { margin-top: 20px; overflow: hidden; } with the inspector of google chrome I can see that the script is adding or removing the active class of myBtnContainer, and adding or removing the show class to the column element (card of my project). but it doesn't hide the unselectioned card, it's still displaying all my project. What am I doing wrong? thanks for your help.
  4. it works !!! I don't understand the logic of it but thank you very much
  5. Hi, i'm trying to have a random image render for each item of my posts list. so i found this <ul> <?php $items = $pages->find("template=project, Year=$page"); foreach ($items as $item){ echo "<li> <div class='item-inner'> <img src='$item->images->first()->url' width=150px alt='Too Bad'> <div class='overlay'> <a href='$item->url'><h5>$item->title</h5></a> </div> </div> </li>"; } ?> </ul> but i don't understand why it renders me http://localhost:8888/PW3Blank/home/projects/date/2019/bj_-_1.jpg%7Cbj_-_2.jpg%7Cbj_-_3.jpg%7Cbj_-_4.jpg-%3Efirst()-%3Eurl I'm sorry to bother but i can't figure out what i'm doing wrong. thanks for your help
  6. sorry for the dumb question I realised it was css related. anyway thanks for the hint .
  7. Hi , I'm having issue with a script i try to integrate to my homepage. it is working just like i wanted but it's covering my title and menu bar which i have fixed on top. i'm not sure if I explain myself right as i'm very new to this. here is the script: <script type="text/javascript"> jQuery(document).ready(function($){ 'use strict'; jQuery('body').backstretch([ <?php foreach($page->images as $image) { echo '"'."$image->url".'",'; } ?> ], {duration: 4000, fade: 500, centeredY: 2000 }); }); </script> thanks for your help.
  8. Thank you very much for all your help Snobjorn. This code doesn't work because i'm trying to have the same template for tag and category. but is this code would be correct? if ($page->parent-> template->name == "tags") { $field_name = "tag"; in that case I would make a template for categories and for tags and have the same template for both childrens
  9. Thank you very much Snobjorn, it works as a charm. Is there a function that retrieve me the type of field so it can change from tags to categories. $items = $pages->find("template=project, "function to find if $page is a tag reference or category" =$page"); the idea is to have only one template that I could use for listing all the project of one category or all the project that shares one tag.
  10. Hi, Sorry to bother again with my Noobies questions but I can't figure out something, It's probably have treated 100 times but as I probably don't have the good vocabulary I can't find anything in the forum. I would like to have a page who sort all my post ( they all have the same template named project) that share a same tag or category ( tag and category are two fields of page reference in the project's template ) so far I'm here <ul> <?php $items = $pages ->get("template=project")->children("tags=$page"); foreach ($items as $item){ echo <li>$item->title</li>; } ?> </ul> Also should I repeat the code with category field or is it better to have two separate templates one for the category list and one for the tag. I appreciate a lot all the help you can give me. my best
  11. thank you elabx this was the problem ?
  12. Thank you very much for your answer. strangely echo $page->category->title; doesn't seem to work but the last example works perfectly
  13. Hi, sorry for the very nubby question but i can't understand why <?php echo $page->categories; ?> renders me 1041 instead of the name of the categorie I define categories being the name of the field I define thanks for your help
×
×
  • Create New...