I have an XML file containing 15 items.
What I'm trying to do is to layout these items in a 3 span div.
where the first item is aligned left, and two consecutive items are aligned right.
here is the website in question.
http://phantom-3.com/leoshop-pack/index.php
I'm referring to the 3 row of items.
I'm not sure how to loop through this so that the output is as expected.
1 item "left" followed by 2 items "right".
Can someone please help me with this logic?
The problem is im using a template built by someone else which is meant to be responsive. I don't want to break the code by fiddling with it as im not that advanced with css. Is there any logic i can pass in php for the code to loop every 3 items. so I can construct the first row (item1:left,item2:right,item3:right) and pick back up at item4 for next loop reapting upto 15 items... ?
Thank you
Related
I am using sphinxsearch + php for full text search in my app.
I need next prev buttons on my product page. For example I run query "Men shoes" it returns me result of 20 shoes (paging limit is 20), then I click into product and open up a product page, and here I have next and previous products. But next and prev should work to specific to my search query "Men shoes". I store my query in session, and I have ID of product. So how can I find the position of these product and increment or decrement it find products I need.
Is it possible to without query-ing the whole table and looping through to find what I need.
While you can* create a cursor solution, it may be simpler to just use offset.
Page 1 is offset zero, page 2 is offset 20, page 3 is 40 and so on.
where you call setLimits, you can set the offset.
*Basically you need a consistent sort order, and need to store the value of the column, as the 'cursor' for paging, and use it for filtering the next page. If sorting by weight, you store the weight of the last result on the page. Then for the next page, you only want weights bedlow that one. (with weights is even more complicated as there can be many results with the same weight, so you need to do multi-column sorting)
I am looking for an optimized way of displaying dynamically generated items sorted and grouped based on initials (like the image below). Groups can have different number of items and therefore also the total number of items is not known.
What would be the best solution to spread the groups across columns(they should remain sorted)?
Currently the groups and items are generated from php and spread across columns(divs) which contain the groups and items within ul and li items.
https://www.dropbox.com/s/ub3mg3twm0eg8b6/columns.jpg
Thanks in advance,
You can use CSS3 columns https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_multi-column_layouts and this will work as a polyfill https://github.com/BetleyWhitehorne/CSS3MultiColumn
Since it looks you just need a push to get started he's what I would do. Since your columns are dynamically generated I assume you're using PHP for that you should:
Count each item in the columns
Count all items on the whole page
Divide that by three
Next you'd output the first third until the last item of the last group
Count all the items in the first column
Next output starting at the first item of the new group and output as many items as in the first group excluding the last group
Output the rest of the items in de last column
Needs some tweaking of course. Good luck!
I have been asked if I could number products in the admin area of OpenCart 1.5.
The numbering would be like:
1
2
3
4
5
etc and continues on the next page.
I am just unsure how to do the count and pull the numbers through into the view.
I've never used OpenCart 1.5 before, however, with a little PHP you could make it work:
Your result array is probably indexed. Add 1 to the index and you have your row number.
For pagination support you just need to use the following equation: (index + (page_size * (page_number - 1)). Then, you'd just add one for each item.
Depending on how your product table is set up, you might also be able to output the primary key of the table. Quite often, those will start at one and increment by one each time. The problem with this, however is that if you delete product #3 then you'll have a gap in your numbers.
Good luck!
I have a category table with sub-categories
Table Structure is:
ID, Category Name, Parent Category
1, A, 0
2, B, 0
3, C, 0
4, A1, 1
5, A2, 1
6, A12, 4
and so on..
I am able to display this in the form of Tree Structure. But I want to display them as Tree Structure with Paging.
Something like,
Say there are 1000 categories.
Every page shows 20 records (in tree like structure)
So, no. of pages = 50
Now, when user clicks on Page Number 2 then he should be shown records from number 21 from the Hierarchical Tree Structure.
So, what I want is that a Tree with Paging.
Please help me in how to do it.
Thanks.
First get the entries which are in the currently selected branch;
then cull them according to the offset.
(You are obviously somewhere storing the currently selected branch, and have some means of setting the position in the pages. Make an ordered list of the sub-nodes in the branch to be displayed, then get the subset between $offset and $offset+$numberOfEntriesToBeShown-1 and display these entries.)
So, according to it I have to create a hierarchical structure on every page and show only some records (acc. to paging). By this method it takes long time load.
I have 3000 records in table with Id, Name, Parent Id
I now create a tree structure on page 1 (of paging) showing first 10 records from array (of tree structure).
Then user goes on 2nd page and again a tree structure is created but records 11-20 are being shown.
So, here every time whole tree is formed first and then only a part is showing.
For 3000 records it takes time to create a complete tree every time and in future if there are more records say 10000 or even more then it will even more time.
Is there some other solution to it.
Thanks.
I am trying to create a pagination with just next and previous links instead of 1,2,3..etc.
So I have say item 1,2,3,4,5 in the database and each item is on one page.
If I am on item 2 page I would like a previous link for item 1 page and a next link for item 3 page...etc
So far I got up to retrieving all the items in the database and created a loop to spit out all the URL in each item. But I don't quite know the best way to strip off all the items except the adjacent items. This is the loop I have so far.
foreach ($item_url as $url) :
echo $url['url'];
endforeach;
This spits out all URL...But how do i proceed to list only the adjacent items and not count the current item I am on...I tried using next($url); to move the pointer if it matches the current item but it didn't work...
Thanks, guys!
Here's a neat resource for paging tabular data without the headache of writing your own code or the need for any PHP at all. Throw all the results into a table (or output them via JSON if you are so inclined) Now, apply the DataTables plugin to the table id and tell it to do pagination. Voila, instant pagination, no brain damage required.