I wonder if somebody could help me please. I’ve been asked to change a pages appears to make it less formulaic. At the moment all of the information is taken from the database and ‘tilled’ across the page. I want to change the tiles so that I have six different rows. One with one result, another with two, one with three and so on.
I don’t know if this is possible or if it is where I would even start so would be grateful for any help at all please.
At the moment the code I’ve got for the current page is:
one main
one medium horizontal (image left, text right)
three small
two medium vertical (both with different coloured backgrounds)
one medium horizontal (image right, text left)
three small
three small
There are probably hundreds of results in total but should be 14 on each page
well for starters, you just listed 7 items for your 6 rows.
If your LAYOUT is the same, but the RESULTS need to be randomized, pull all the results (I assume you’re getting this info from a DB), [FPHP]shuffle[/FPHP] the array, and then stick whatever got put into array slot 1 as the first thing, the next into the next, etc.
If the LAYOUT is to be randomized, you’re going to need parameters for what you can put where, as sticking vertical things in with horizontal things at random gets messy.
The layout will stay the same and the results will be ordered by the date they were uploaded. I don’t know if that make any difference.
Also I wasn’t sure what you meant about ‘you just listed 7 items for your 6 row’. Sorry I think my brain’s over heating!! I counted 14 items, 1 on the first row, 1 on the second, 3 on the third, 2 on the fourth, 1 on the fifth then 3 on the sixth and agin on the seventh
How do I actually get them into that layout? At the moment I’ve got every single result looking the same. I’m pretty new to php so don’t know how to do this but essentially the results are just being looped through and put into the same layout, but I don’t know how to change the code so that it varies how the results look depending on what line they’re on if that makes sense.
Design the entire page layout first. (use placeholders for the data if necessary) Then put the data into the layout; Rather than trying to change the layout as you process the data.
Sorry to ask such a dumb question but that’s the part I’m having problems with. How do I actually get the data into each layout style? I’ve used divs for each section, but don’t know how to dynamically populate it.
I can output the results as an array using this:
<?php
$i = 1;
do {
if (isset($GLOBALS['column' . $i])) {
$continue = true;
print_r($GLOBALS['column' . $i]);
}
else {
$continue = false;
}
$i++;
} while ($continue);
?>
require 'different_function_layouts.php'; // to be written
$i = 1;
do {
if (isset($GLOBALS['column' . $i])) {
$continue = true;
# print_r($GLOBALS['column' . $i]);
switch( $i )
{
case 1: // one medium horizontal (image left, text right)
fn_div_1($GLOBALS, $i);
break;
case 2: // three small
fn_div_2($GLOBALS, $i);
break;
case 3: // two medium vertical (both with different coloured backgrounds)
fn_div_3($GLOBALS, $i);
break;
case 4: // one medium horizontal (image right, text left)
fn_div_4($GLOBALS, $i);
break;
case 5: // three small
fn_div_5($GLOBALS, $i);
break;
case 6: // three small
fn_div_5($GLOBALS, $i);
break;
}// endswitch
}else{
$continue = false;
}
$i++;
} while ($continue);
I’m really sorry to be a pain but I tried that and it didn’t work - I think because there’s only one column (with 14 results in it). Is it possible to do something like this:
get all results, then for first row show just 1st item. Then second row show 2nd result, for third row show 3rd, 4th and 5th, fourth row show 6th and 7th etc?
Thank you so much, I can’t give a link as it’s on a private network while it’s in development but I’ve attached the file anyway. I’ve put the new style in one div and the current/old style in another.
Thank you for having a look at it for me, I’m really grateful.
Oe thing I don’t understand though - using the example you gave above would I still be able to change it so that it gave me the different rows I’m after?
As you can see the row order can be changed and remming results_XXX.php which are not required will make debugging easier. Once the the selected result_XXX.php is doing exactly what your want it to do then move on to the next result_XXX.php.