I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« on: Mar 17, 2007, 03:35:44 PM »
Hi All,
I think foreach is a php statement?
Anyway, I have a database application (purchased script) for a directory site. In the new upgrade they appear to have removed the functionality that allowed one to limit the number of results for 2 particular pages to a certain number of pages or results. I now have 2 sections of my site with 18 pages - totally unacceptable.
I would like to limit the results to 20 total links - rather than every link in the directory, which is what it is now doing.
With the foreach, could I put some sort of counter and when it reaches 20 bust out of the foreach loop.
I believe I could figure out the counter part, but how do I signal to the foreach to quit? Or do I have to let the foreach run through the entire database and using a counter and an if statement only display the first 20?
I hope that makes sense. Any suggestions on how to do this?
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #2 on: Mar 17, 2007, 03:57:34 PM »
This loop is already being used, can I use the same thing, but just change the name by replacing links with say links2? Am I correct that it is better to use a different name for a loop in the same page?
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #5 on: Mar 17, 2007, 04:19:24 PM »
It's the popular-links.tpl and the new-links.tpl. The if-then I showed is used to display ads between the listings and from the index.tpl; would seem that this issue is similar in that I need to count the number of listings fetched from the database. Part of me is hoping that there's a way to break out of the foreach to save some processing and page loading time.
I can't believe they dropped the admin panel functionality to limit how many links are displayed on these 2 pages. But then again why should I be suprised with anything that crowd does anymore?
BTW if you know where the query is, you could just add a LIMIT 20 in the end, without modifying any template
I'm not sure that would work, because it would limit the listings in the categories to 20 as well. I think they are reusing the same query for everytime links are displayed.
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #11 on: Mar 17, 2007, 05:29:21 PM »
That didn't change it either. The foreach statement is surrounded by statements that create the navigation menu. I thought it might be coming from that and tried changing that too:
I tried changing $total_links to the actual value 20 and to 2 and it didn't change anything which seems odd to me. Seems like that should have done something even if it broke the page, but to do nothing seems really strange.
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #12 on: Mar 17, 2007, 05:51:32 PM »
Oh, good grief, I just remembered they changed and no longer use popular-links.tpl and new-links.tpl. Both of those pages are now running off the same template file. Here's the section of that file that controls link display along with my formatting code for the content box:
Oh, good grief, I just remembered they changed and no longer use popular-links.tpl and new-links.tpl. Both of those pages are now running off the same template file. Here's the section of that file that controls link display along with my formatting code for the content box:
I asked that before , what is the name of this file?
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #15 on: Mar 18, 2007, 04:19:42 PM »
That file is from the 2.1 version - listings.tpl
I'm terribly sorry, I had forgotten they had changed this from the old way of having a template file for each of those pages. Seems more streamlined this way, but has only added more confusion to an already difficult upgrade.
I'm terribly sorry, I had forgotten they had changed this from the old way of having a template file for each of those pages. Seems more streamlined this way, but has only added more confusion to an already difficult upgrade.
I think your template is not yet upgraded right?
I have this if/foreach in one of their def. templates:
I am a fanatic. So?
Gender:
Posts: 584
3633 credits Members referred : 2
« Reply #17 on: Mar 19, 2007, 09:31:01 PM »
I should have the latest version's template.
Yes, it is dynamically generating the number of pages depending upon a control panel setting for how many links to display on each page.
Do you think the easiest solution would be to break the navigation menu part to only put links to the first and second pages? It would still generate the other pages, but one would have to know the file name to get to it.