Jump to content

Search the Community

Showing results for tags 'loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 16 results

  1. I want to split my output of an image array, see my code here: <div class="row"> <?php foreach($page->umf_imgs as $image) {echo "<div class='one-fourth column refs'><img src='$image->url'></div>";} ?> </div> <div class="row"> <?php foreach($page->umf_imgs as $image) {echo "<div class='one-fourth column refs'><img src='$image->url'></div>";} ?> </div> <div class="row"> <?php foreach($page->umf_imgs as $image) {echo "<div class='one-fourth column refs'><img src='$image->url'></div>";} ?> </div> The number of images is 11, but I only want to add four in a row. Is it possible to grab them, e.g. image 1-4, image 5-8, image 9-12?
  2. hi everyone I am trying get a full width sub-menu on 3rd item in menu or navbar which is coming from a loop. i was hoping this can be done by using jquery by targeting 3rd element in navbar but jquery is blocked in some browser by default so is there any other method I can do this
  3. I have a page field on my home template with output set to multiple pages (PageArray). I can echo its value, 1111|2222, or foreach $nav as $p echo $p, 11112222. But when I do this that I need to, it doesn't work: foreach ($mainnav as $p) { if($page->rootParent->id == $p->id) $current = 'style="background: #fff;"'; else $current = ''; echo "<a href='{$pages->get($p)->url}' $current class='{$pages->get($p)->name}'>" . strToUpper($pages->get($p)->name) . "</a>"; } I get: I've tried the conditional in the code with one and three = signs.
  4. Hi. I have a setup that sends an email to all users that have subscribed to a category. When a post i published in a category, emails needs to be sent to all those users. For instance, I have 3 user subscribed, so 3 emails should be sent. However, 6 emails are sent and some of the emails are sent to 2 and 3 person at the same time. Please see attached file for what I mean. if( $page->template == "post" && !$page->isTrash() ){ if( $page->id && $page->isChanged( 'status' ) && !$page->is( Page::statusUnpublished ) ) { $from = wire('config')->adminEmail; foreach( wire( 'users' )->find( "roles=partner, location=$page->location, branch=$page->branch" ) as $user_data ){ $mail = wireMail(); $mail->to( array( $user_data->email => $user_data->contact_name ) ); $mail->from( $from, 'My Company' ); $mail->subject( 'Hi '.$user_data->contact_name.'<br>My subject' ); $mail->bodyHTML( 'My message' ); $mail->send(); } } }
  5. I just happened upon something that I think is curious, and I'm wondering if this is default behavior. So help me because I know nothing. While writing a module, i logged something in wire('log') inside the module's init() function. I was surprised to see that the text was being logged multiple times continuously. So I tried to open a small random module and logged something in its init() function as well, and the same thing happened - the text being logged many times. My question is, is this supposed to happen? I just want to understand what's going on. My concern is that if I do something huge in the init function, it will get called repeatedly, as with the log, and cause performance issue. Please note that these are both autoload modules. I was expecting them to log at least once when I refresh, but not continuously like what happened. Please let me know. Thanks.
  6. Hello guys. I am almost on the final line of building my second complete website with ProcessWire and got stuck a bit on the recipe nutrition presentation. I am not sure if I would be able to explain it promptly, but will do my best. So I have the code in my HTML template: So to fill up the values in the frontend, I am using a simple TextArea field and dropping the following content: As far as I needed to split the text field into separate lines and every line into 3 parts (nutrition name, quantity and measure) I used regex code to sort everything through and the results are OK. Now the issue I am facing is that as per the theme, I need to assign class to left or right block and on top of that to close the nutrition-detail div after every right-box div. For the class I added $counter and using odd:even managed to assign the class of left-box & right-box. But I am having difficulty to insert the opening div of nutrition-detail on the beginning of every row and the closing div after the second block. Here is the code that sort of works, but is not inserting the divs properly: Any suggestions how to go around or some simple function to introduce to make it work? I tried to add another check for odd:even and if the result is odd, to insert the <div class="nutrition-detail"> and close the div if even, but I am still missing something...
  7. My brain is probably just tiring out on me right this moment, I'm hoping that by the time I write out my problem I'll see the way through it. If you're reading this, it didn't work. Structure in question is: Series Page Product pages Page Fields for each product page Some of these fields are repeaters Fields within the repeater I have made an array of page fields so I don't have to keep track of them all as I develop: $listings = $page->children; // grab all the published children of the Series page foreach($listings as $l) { // loop through the children foreach($l->fields as $f) { } // loop through each child's page fields where they have a value set } Then I break down how to handle each type of field: if($f->type == 'FieldtypeFile') { } elseif($f->type == 'FieldtypeDatetime'||$f->name == 'prod_status_pages'||$f->type == 'FieldtypeImage'){ } elseif($f->type == 'FieldtypePage'){ } These are all largely working as expected (though I do have a couple of offset/isset exceptions to clean up...) It's when I get to the repeaters that I run into trouble getting the API calls to work. Just cycling through the fields as above, the output for a FieldtypeRepeater is the ID of the repeater in that field's array. Everything I read suggests I should treat a repeater the same as I would treat a page, which leads me to the following code. elseif($f->type == 'FieldtypeRepeater'){ // Repeaters need special treatment otherwise output is just ID $th .= "<th><b>{$f->label}</b></th>\n"; $trows = ""; // creating an empty variable to build my foreach into foreach($f->fields as $rf){ // looping, I hope, through the fields of the given Repeater ID $trows .= "{$rf->label}: {$f->get($rf)->title} ({$rf->type})<br />\n"; // add an entry to the variable } $rows .= "<td style='padding: 8px 16px; vertical-align: middle;'>".$trows."<br />\n ({$f->type})</td>\n"; // back out to rendering the Repeater field } What I would hope would output in the HTML I've been building is something like: <td style='...'>Lo temp: -40 (Integer)<br /> Hi temp: 75 (Integer)<br /> Storage Lo: -40 (Integer)<br /> Storage Hi: 85 (Integer)<br /> Functional to: 85 (Integer)<br /> (FieldtypeRepeater)</td> So what I'm trying to do here is loop through the populated fields in the unknown Repeater field, and output them as a simple (so far) text list of the repeater.field and its value (and then its type for my reference). I'm afraid typing this out has fixed some syntax but not enough to get this working as I'd hoped. Please note not all Repeater fields are integers. Some also have floats, files, or options, and probably a couple others I'm forgetting. I appreciate your time in taking a look at this!
  8. Hello all. Yesterday working on my Cooking Recipes profile I stumbled across an interesting issue - how to show pages published/created on a specific time interval without the use of any plugins but just the default API of PW. Thanks to @abdus the sollution was implemented and was working perfectly fine (here) Everything was good until I started working on my main page and discovered that our web designer made the recipes appear in threee columns and to differentiate the columns he used 3 different classes (first, second, last). So it was supposed to look like this: <li><class="cs-recipes first"></li> | <li><class="cs-recipes second"></li> | <li><class="cs-recipes last"></li> At first I thought it would be easy to just create another loop and insert it within the first one, but that got me unprepared as instead of 5 posts (as the limit was), I was showing 15. So moving here and there, trying and trying for quite some time to find a solution, I got stuck and asked for some help. Mr @abdus saved the day again offering something simple and most important - fully working. As far as it was a PM, I decided that it would be a shame if I don't share it with anybody else who might sooner or later search for similar functionality, so here is the complete sollution that works perfectly fine and applies the first, second, last as it should without creating unnecessary loops etc.: Hope it helps and don't thank me, I am just the messenger
  9. Hello, I am just started playing around with processwire and it looks very nice. I am not a real developer (hopefully start this education next year). I am working on a template where I took some javascript from aother template. For the front page I have created a repeating field blok wich holds a text blok, a background color and a waves color and waves checkbox (0/1). This all is working. But when the waves checkbox is unchecked I want to add to the div display:none. This part is not working as it is part of the for each for the block (I think). I am a bit stuck, can anyboy give me a hint? testpage is pw.webhoes.nl This is the for each loop <?php foreach($page->extra_body as $extra_bodies) { ?> <div class="container-fullwidth" style="background-color:<?php echo "{$extra_bodies->extra_bg_color}"; ?>"> <div class="container"> <section> <div class="row"> <div class="col-md-12 body-front wow fadeInUp animated"> <?php echo "<p>{$extra_bodies->extra_body_text}</p>"; ?> <?php echo "<p>{$extra_bodies->extra_waves}</p>"; ?> </div> </div> </section> </div> <script type="text/javascript">var waves = <?php echo "{$extra_bodies->extra_waves}";?>; if (waves = 0) document.getElementById('svg_waves').style.display = "none"</script> <div class="svg_waves"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 157"> <g id="footer_wave" fill="none"> <g id="Artboard" fill="<?php echo "{$extra_bodies->extra_wave_color}" ; ?>"> <g id="waves" transform="matrix(-1 0 0 1 1649 31)"> <path id="wave--bg" d="M62.871 104.03C216.871 87.324 286 79.324 589 79.324S958 125 1249 125s445.587 1 445.587 1L1678 225 183.67 235.324S-91.129 120.734 62.871 104.03z"/> <path id="wave--bottom" d="M72.868 151.295C103.996 138.363 484.122 47.5 650.155 47.5c166.034 0 320.54 45.056 611.54 45.056 291 0 464.044-67.495 464.044-67.495l-80 132.939-1437 32s-167-98.777-135.871-111.71v73.005z" opacity=".06" transform="matrix(-1 0 0 1 1794.739 0)"/> <path id="wave--middle" d="M43 2c154-9.807 423.81 29.65 538.81 45.5C696.81 63.35 966 94 1257 94c291 0 457.203-42.22 457.203-42.22l-69.753 97.447H201.001S-111 11.807 43 2z" opacity=".15"/> <path id="wave--top" d="M616.074 103.938c-293.347 0-472.782-20.373-472.782-20.373l70.315 97.447h1455.087s329.601-143.286 174.36-153.093c-155.242-9.807-605.136 26.69-721.063 42.54-115.927 15.85-212.571 33.479-505.917 33.479z" opacity=".1"/> </g> </g> </g> </svg> </div> </div> <?php } ?> Below is my code for the home.php template that includes the above code. <?php namespace ProcessWire; ?> <?php /* include_once("./_header.inc"); */ // home.php (homepage) template file. // See README.txt for more information ?> <div class="container"> <header> <!-- Top Navbar --> <nav id="headeroom" class="navbar navbar-fixed-top navbar-intro navbar-intro-full headeroom-padd" role="navigation"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar-collapse-fixed-top"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand navbar-brand-img-lg" href="/"><img src="<?php echo $config->urls->templates?>/images/Logo_webhoes.png" alt="Webhoes" class="img-responsive"></a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="main-navbar-collapse-fixed-top"> <?php /* <div id="search-wrap" class="navbar-form navbar-right"> <form class='search' action='<?php echo $pages->get('template=search')->url; ?>' method='get'> <input type='text' name='q' placeholder='Search' value='<?php echo $sanitizer->entities($input->whitelist('q')); ?>' /> <button type='submit' name='submit'>Zoeken</button> </form> </div> */ ?> <ul class="nav navbar-nav navbar-right"> <?php foreach($homepage->and($homepage->children) as $item) { if($item->id == $page->rootParent->id) { echo "<li class='current'>"; } else { echo "<li>"; } echo "<a href='$item->url'>$item->title</a></li>"; } // output an "Edit" link if this page happens to be editable by the current user if($page->editable()) echo "<li class='edit'><a href='$page->editUrl'>Edit</a></li>"; ?></ul> </div><!-- /.navbar-collapse --> </div> </nav> </header> </div> <?php /* ?> <div class="container-fullwidth animated fadeIn"> <section id="zoom-out-header"> <div id="zoom-out-background" style="background: url('[[*blog_main_image]]') no-repeat center center; background-size: cover; "></div> <div id="zoom-out-tagline"> <div class="container"> <div class="row no-border no-marg-tb"> <div class="col-md-12"> <h1 class="no-marg-b backg-black-transp20 color-light text-center padd-20">$page->title; </h1> </div> </div> </div> </div> </section> </div> */ ?> <?php // if there are images, lets choose one to output in the sidebar if(count($page->images)) { // if the page has images on it, grab one of them randomly... $image = $page->images->getRandom(); // resize it to 400 pixels wide //$image = $image->width(1140); uit om responsive te maken // output the image at the top of the sidebar... $header = $image->url; // ...and append sidebar text under the image // $sidebar .= $page->sidebar; } else { // no images... // append sidebar text if the page has it // $sidebar = $page->sidebar; echo "$config->urls->templates"; ?>images/full-bg.jpg" <?php } ?> <!-- Full Page Image Background Carousel Header --> <div id="carouselFade" class="container-fullwidth container-marg-b color-primary-backg carousel carousel-fade slide bs-full-slider bs-full-slider-h50 animated fadeInDown"> <!-- Indicators --> <ol class="carousel-indicators z-index-2"> <!--<li data-target="#carouselFade" data-slide-to="[[+idx:decr]]" [[+idx:is=`1`:then=`class="active"`]]></li> --> </ol> <!-- Wrapper for Slides --> <div class="carousel-inner"> <div class="item active"> <div class="fill header-fill" style="background-image:url(<?php echo $header; ?>)"> </div> <div class="carousel-caption height-100 caption-vertical z-index-1" > <div class="caption-vertical-item"> <h1><?php echo "$page->title"; ?> </h1> <p class="lead marg-b20"><?php echo "$page->headline"; ?></p> </div> </div> </div> </div> <!-- Controls --> <a class="left carousel-control z-index-2" href="#carouselFade" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> </a> <a class="right carousel-control z-index-2" href="#carouselFade" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> </a> </div> </div> <div class="container"> <section> <div class="row"> <div class="col-md-12"> <!-- breadcrumbs --> <div class='breadcrumbs'><?php // breadcrumbs are the current page's parents foreach($page->parents() as $item) { echo "<span><a href='$item->url'>$item->title</a></span> "; } // optionally output the current page as the last item echo "<span>$page->title</span> "; ?></div> </div> </div> </section> </div> <div class="container-fullwidth" style="background-color:<?php echo $page->bodyBackgroundColor; ?>"> <div class="container"> <section> <div class="row"> <div class="col-md-12 body-front"> <?php $page->headline; ?> <div class="wow fadeInUp animated"> <?php echo $content; ?> </div> <?php // Primary content is the page body copy and navigation to children. // See the _func.php file for the renderNav() function example $content = $page->body . renderNav($page->children); ?> </div> </div> </section> </div> <div class="svg_waves"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 157"><g id="footer_wave" fill="none"><g id="Artboard" fill="<?php echo $page->bodyWavesColor; ?>"><g id="waves" transform="matrix(-1 0 0 1 1649 31)"><path id="wave--bg" d="M62.871 104.03C216.871 87.324 286 79.324 589 79.324S958 125 1249 125s445.587 1 445.587 1L1678 225 183.67 235.324S-91.129 120.734 62.871 104.03z"/><path id="wave--bottom" d="M72.868 151.295C103.996 138.363 484.122 47.5 650.155 47.5c166.034 0 320.54 45.056 611.54 45.056 291 0 464.044-67.495 464.044-67.495l-80 132.939-1437 32s-167-98.777-135.871-111.71v73.005z" opacity=".06" transform="matrix(-1 0 0 1 1794.739 0)"/><path id="wave--middle" d="M43 2c154-9.807 423.81 29.65 538.81 45.5C696.81 63.35 966 94 1257 94c291 0 457.203-42.22 457.203-42.22l-69.753 97.447H201.001S-111 11.807 43 2z" opacity=".15"/><path id="wave--top" d="M616.074 103.938c-293.347 0-472.782-20.373-472.782-20.373l70.315 97.447h1455.087s329.601-143.286 174.36-153.093c-155.242-9.807-605.136 26.69-721.063 42.54-115.927 15.85-212.571 33.479-505.917 33.479z" opacity=".1"/></g></g></g></svg></div> </div> <div class="container-fullwidth" style="background-color:#<?php echo $page->body2BackgroundColor; ?>"> <div class="container"> <section> <div class="row"> <div class="col-md-12 body-front wow fadeInUp animated"> <?php echo "$page->body2"; ?> </div> </div> </section> </div> <div class="svg_waves"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 157"><g id="footer_wave" fill="none"><g id="Artboard" fill="#<?php echo $page->body2WavesColor; ?>"><g id="waves" transform="matrix(-1 0 0 1 1649 31)"><path id="wave--bg" d="M62.871 104.03C216.871 87.324 286 79.324 589 79.324S958 125 1249 125s445.587 1 445.587 1L1678 225 183.67 235.324S-91.129 120.734 62.871 104.03z"/><path id="wave--bottom" d="M72.868 151.295C103.996 138.363 484.122 47.5 650.155 47.5c166.034 0 320.54 45.056 611.54 45.056 291 0 464.044-67.495 464.044-67.495l-80 132.939-1437 32s-167-98.777-135.871-111.71v73.005z" opacity=".06" transform="matrix(-1 0 0 1 1794.739 0)"/><path id="wave--middle" d="M43 2c154-9.807 423.81 29.65 538.81 45.5C696.81 63.35 966 94 1257 94c291 0 457.203-42.22 457.203-42.22l-69.753 97.447H201.001S-111 11.807 43 2z" opacity=".15"/><path id="wave--top" d="M616.074 103.938c-293.347 0-472.782-20.373-472.782-20.373l70.315 97.447h1455.087s329.601-143.286 174.36-153.093c-155.242-9.807-605.136 26.69-721.063 42.54-115.927 15.85-212.571 33.479-505.917 33.479z" opacity=".1"/></g></g></g></svg></div> </div> <?php foreach($page->extra_body as $extra_bodies) { ?> <div class="container-fullwidth" style="background-color:<?php echo "{$extra_bodies->extra_bg_color}"; ?>"> <div class="container"> <section> <div class="row"> <div class="col-md-12 body-front wow fadeInUp animated"> <?php echo "<p>{$extra_bodies->extra_body_text}</p>"; ?> <?php echo "<p>{$extra_bodies->extra_waves}</p>"; ?> </div> </div> </section> </div> <script type="text/javascript">var waves = <?php echo "{$extra_bodies->extra_waves}";?>; if (waves = 0) document.getElementById('svg_waves').style.display = "none"</script> <div class="svg_waves"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 157"> <g id="footer_wave" fill="none"> <g id="Artboard" fill="<?php echo "{$extra_bodies->extra_wave_color}" ; ?>"> <g id="waves" transform="matrix(-1 0 0 1 1649 31)"> <path id="wave--bg" d="M62.871 104.03C216.871 87.324 286 79.324 589 79.324S958 125 1249 125s445.587 1 445.587 1L1678 225 183.67 235.324S-91.129 120.734 62.871 104.03z"/> <path id="wave--bottom" d="M72.868 151.295C103.996 138.363 484.122 47.5 650.155 47.5c166.034 0 320.54 45.056 611.54 45.056 291 0 464.044-67.495 464.044-67.495l-80 132.939-1437 32s-167-98.777-135.871-111.71v73.005z" opacity=".06" transform="matrix(-1 0 0 1 1794.739 0)"/> <path id="wave--middle" d="M43 2c154-9.807 423.81 29.65 538.81 45.5C696.81 63.35 966 94 1257 94c291 0 457.203-42.22 457.203-42.22l-69.753 97.447H201.001S-111 11.807 43 2z" opacity=".15"/> <path id="wave--top" d="M616.074 103.938c-293.347 0-472.782-20.373-472.782-20.373l70.315 97.447h1455.087s329.601-143.286 174.36-153.093c-155.242-9.807-605.136 26.69-721.063 42.54-115.927 15.85-212.571 33.479-505.917 33.479z" opacity=".1"/> </g> </g> </g> </svg> </div> </div> <?php } ?>
  10. Hello Real Beginner here. I am trying to loop the children of a product ( Keramik ) I have. They should look as an image with text underneath ( Example with bicycle tires ). I create for each product an own child page . I can't get my head around this... Thanks for all the help. Jakob I would like to have 3 Images with text on each row My structure: Each child has a Title, img and description
  11. I want to create a basic breadcrumb menu on my site and i'm using this code <?php $parents = $page->parents(); ?> <?php foreach( $parents as $item): ?> <span><a href='<?php echo $item->url; ?>'><?php echo $item->title; ?></a></span> <?php endforeach; ?> <span><?php echo $page->title; ?></span> When i print_r $page->parents() it has the correct count and urls. But when i go to foreach it misses out a step. for example if i was on the curriculum page it should say: home > about us > curriculum but it just echo's out: home > curriculum Am i doing the foreach wrong? i followed the example code Ryan posted for making a breadcrumb menu.
  12. Hey I'm stuck with a issue how to filter repeater results depending on content. I have a few Option fields where you can select "yes", "no" or then leave it blank "". I got my loop working and I'm able to skip content that has not been set. Now I just need a filter for the loop. <? foreach($pages->get("/content/")->children as $c): ?> <div> <p> <?php if($c->titles) echo $c->titles; ?> </p> </div> <? endforeach;?> I was able to make a if-statement which checked if($c->Selector=="no"): but as it was in the loop, it kinda bugged out. Never got it working either outside the loop... One really hacky way I thought about was using CSS Classes to set classnames, and that way split what is shown and what is not. This is a really bad way as it still loads all the content for each Selector value. What I'm looking for is eg. a filter that every Selector with value "yes" will be looped, others dismissed. Any ideas how to work on with this?
  13. i am trying to create a product carousel in PW from last few days but can't figure out what i am doing wrong. here is HTML of carousel which is working fine. <div class="box producttabs"> <div class="tab-nav"> <ul id="producttabs304244223" class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#tab-latest304244223">First Tab</a></li> <li><a data-toggle="tab" href="#tab-featured304244223">Second Tab</a></li> </ul> </div> <div class="tab-content"> <div id="tab-latest304244223" class="tab-pane box-products tabcarousel304244223 slide active"> <div class=""> <a data-slide="prev" href="#tab-latest304244223" class="carousel-control left">‹</a> <a data-slide="next" href="#tab-latest304244223" class="carousel-control right">›</a> </div> <div class="carousel-inner "> <!-- repeat --> <div class="item active"> <div class="row-fluid box-product"> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-4.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-5.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-6.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-7.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> </div> </div> <!-- repeat --> </div> </div> <!-- end of tab --> <div id="tab-featured304244223" class="tab-pane box-products tabcarousel304244223 slide"> <div class=""> <a data-slide="prev" href="#tab-featured304244223" class="carousel-control left">‹</a> <a data-slide="next" href="#tab-featured304244223" class="carousel-control right">›</a> </div> <div class="carousel-inner "> <div class="item active"> <div class="row-fluid box-product"> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-8.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-1.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-2.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-3.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> </div> </div> <div class="item "> <div class="row-fluid box-product"> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-5.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-6.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-7.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-8.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> </div> </div> </div> </div> </div> </div> if you see in above HTML code there is two tabs and product carousel. one thing important is each 4 items are inclose in <div class="item"> and first div of tab will be <div class="item active"> i am using bellow code in PW but output is coming wrong and page disturb <div class="tab-content"> <div id="tab-latest304244223" class="tab-pane box-products tabcarousel304244223 slide active"> <?php $children=$pages->find("template=product,product_cat=1014,show_main>0"); if($children->getTotal() >0){ ?> <div class=""> <a data-slide="prev" href="#tab-latest304244223" class="carousel-control left">‹</a> <a data-slide="next" href="#tab-latest304244223" class="carousel-control right">›</a> </div> <div class="carousel-inner "> <?php $j=1; $active="active"; foreach($children as $child) { if($j==1) { echo "<div class=\"item $active\"><div class=\"row-fluid box-product\">"; $active=""; } ?> <div class="span3 product-block"><div class="product-inner"> <div class="image"> <a href="#"><img alt="Loves or pursues" src="products/image-4.jpg"></a> </div> <div class="wrap-infor"> <div class="name"><a href="#">Loves or pursues</a></div> <div class="description">Samsung Galaxy Tab 10.1, is the world's thinnest tablet, m...</div> </div> </div> </div> <?php if($j==5){ echo "</div></div>"; $j=1; } ?> <?php $j++; } echo "</div></div>"; } ?> </div> </div> </div> if you see in my code i am using variable $j to count number of products and when product reach 5 i end the two div and make $j to 1 to create another <div class="item"> but active is only once. i am also trying to close two more div at end. thanks for heloping
  14. I am finishing up my first processwire site (yay), and this last bit is giving me a bit of a headache: For a news slider, I want to output x number of posts, with three posts per slide. (for a theoretically unlimited number of slides) I figure in theory this should work something like the code below, however the looping logic, among other things is still somewhat beyond me: <?php $items_per_page = 3; $start = ($pages->get("/news/")->find("sort=sort")->pageNum - 1) * $items_per_page; $total = count($pages->get("/news/")->find("sort=sort")); $slicedarticles = $pages->get("/news/")->find("sort=sort")->slice($start, $items_per_page); foreach ($slicedarticles as $slicedarticle => $total) { echo "<div class='slide'>"; foreach ($slicedarticle as $article) { echo "<h3>{$article->title}</h3><p>{$article->body}</p>"; } echo "</div>"; } ?> Can someone point me in the right direction with this? Much appreciated! Cheers, Phil
  15. Hi there, for some reason I do not succeed in doing a simple iteration (in this case with images): <?php $number_of_images = count($pages->get(1012)->images); foreach($pages->get(1012)->images as $image) { $thumbnail = $image->size(118,112); echo "<a href='{$image->url}'><img class='photo' src='{$thumbnail->url}' alt='{$image->description}' /></a>"; if ($number_of_images % 3 == 0) { echo "<p>Insert</p>";} } ?> In this case, there a 5 images attached to 1012, if I echo $number_of_images inside the foreach loop it prints "5". But on the other hand this variable doesn't react on my "$number_of_images % 3 == 0", meaning that it does not insert the <p>...-Chunk every 3 images. Can you help me to find the error in my approach or code? Thanks in advance! marcus
  16. Was just wondering how feasible/complicated it would be to display 3 blog entries, followed by 3 images which will be stored in the blog-index page, followed by the next 3 blog entries, then the next 3 images and so on and so-forth? I'm currently converting a static site (where this was obviously simple) and as a PHP beginner, I would ideally like to know whether the code will become so complicated that it's better to say to the client "Hey let's do this a different way". I had a quick play around and I made a blog entries loop then an images loop, problem is I don't know if it's possible to loop them within another loop... <?php // Show 3 blog entries $entries = $page->children("sort=-sort, limit=3"); $count = 0; foreach ($entries as $entry) { $count++; $class = "blog_box"; if ($entry == $entries->last()) {$class .= " blog_box_last"; } if ($entry == $entries->first()) {$class .= " blog_box_first"; } if (0 == $count % 2) { $class .= " blog_box_even"; } ?> <div class="<?php echo $class; ?>"> <div class="blog_text"> <h3><?php echo $entry->title; ?></h3> <h6><?php echo $entry->entry_date; ?></h6> <p><?php echo $entry->body; ?></p> </div><!-- /.blog_text --> <?php if ($entry->image) { $image = $entry->image->width(350); ?> <img src="<?php echo $image->url; ?>" width="<?php echo $image->width; ?>" alt="<?php echo $entry->title; ?>" /> <?php } ?> <div class="clear"></div><!-- /.clear --> </div><!-- /.blog_box --> <?php } ?> // Show 3 blog images <?php $blog_images = $page->get("image_uploads")->find("limit=3"); foreach ($blog_images as $img) { $b_img = $img->size(200,140); ?> <img src="<?php echo $b_img->url; ?>" width="<?php echo $b_img->width; ?>" height="<?php echo $b_img->height; ?>" alt="<?php echo $b_img->description; ?>" class="small_frame" /> <?php } ?>
×
×
  • Create New...