How to set up the number of categories on the main page

You made an own skin or theme for phpMyFAQ. You can share it here with others!

Moderator: Thorsten

Post Reply
tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

How to set up the number of categories on the main page

Post by tselyuloza » Wed May 29, 2013 8:40 pm

Hello,

Where can i set up the number of categories displayed on the main page? For example, i have 50 categories, and for now all they are displayed on the main page that stretches the page down. In my case i want 10 categories to be displayed on the main page. I haven't find a proper line in constants.php file. So, where can i do this?

The same question relates to the most popular searches variable. Where can i change it?

Thanks in advance!

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Thu May 30, 2013 7:20 pm

Hi,

what about moving some categories to subcategories? Otherwise I can show you where to hack the code to get only 10 categories.

You can set the number of the most popular search terms in the configuration section for search

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Thu May 30, 2013 8:25 pm

1) Otherwise I can show you where to hack the code to get only 10 categories. - it will be the best way out.


2) You can set the number of the most popular search terms in the configuration section for search - seems, this is the code i need. but it does not help me. 10 most popular searches are always displayed. you know, when i found the default value was 7, i was surprised cause 10 items were always displayed in my case.

BTW, i use phpmyfaq-2.7.9.

/**
* Returns the most popular searches
*
* @param integer $numResults Number of Results, default: 7
* @param boolean $withLang Should the language be included in the result?
*
* @return array
*/
public function getMostPopularSearches($numResults = 5, $withLang = false)
{
$searchResult = array();

$byLang = $withLang ? ', lang' : '';
$query = sprintf("
SELECT
id, searchterm, COUNT(searchterm) AS number %s
FROM
%s
GROUP BY
searchterm %s
ORDER BY
number
DESC",
$byLang,
$this->_table,
$byLang);

$result = $this->db->query($query);

if (false !== $result) {
$i = 0;
while ($row = $this->db->fetch_object($result)) {
if ($i < $numResults) {
$searchResult[] = (array)$row;
}
$i++;
}
}


Thanks in advance!
Last edited by tselyuloza on Fri May 31, 2013 1:57 pm, edited 1 time in total.

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Fri May 31, 2013 6:21 am

Hi,

I'll check it for 2.8

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Fri May 31, 2013 10:55 am

Otherwise I can show you where to hack the code to get only 10 categories - i am still wating for your help on this issue ;-)

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Fri May 31, 2013 11:36 am

Hi,

I'm only working on phpMyFAQ during my free time, it'll take some time

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Mon Jun 10, 2013 2:11 pm

Hi,

Do you have any update for me? ;)

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Wed Jun 12, 2013 8:54 pm

Hi,

in inc/PMF/Helper/Category.php, line 62

Change

Code: Select all

            for ($y = 0 ;$y < $numCategories; $y = $this->Category->getNextLineTree($y)) {
to

Code: Select all

            for ($y = 0 ;$y < 10; $y = $this->Category->getNextLineTree($y)) {
I didn't tested that but should work.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Thu Jun 13, 2013 1:28 pm

It works. Thank u a lot!

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Fri Jun 14, 2013 1:02 pm

HI, i have one more question.
I want to disable the language selection and make English as a default language regardless of the browser language. Seems, i need this file \inc\Language.php but where i should change the code?
Thanks in advance!

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Fri Jun 14, 2013 1:13 pm

HI,

you don't have to change code. Remove the language selection from the index.tpl template and disable the automatic detection in the main config

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Fri Jun 14, 2013 2:14 pm

"automatic detection in the main config" - if i'm not mistaken you are talking about the following piece of code:
can you give me a hint at what lines should be disabled ;) cause my attempts didn't give me any result.

// get language (default: english)
$Language = new PMF_Language();
$LANGCODE = $Language->setLanguage($faqconfig->get('main.languageDetection'), $faqconfig->get('main.language'));
//Preload English strings
require_once PMF_ROOT_DIR . '/lang/language_en.php';

if (isset($LANGCODE) && PMF_Language::isASupportedLanguage($LANGCODE)) {
// Overwrite English strings with the ones we have in the current language
if (! file_exists(PMF_ROOT_DIR . '/lang/language_' . $LANGCODE . '.php')) {
$LANGCODE = 'en';
}
require_once PMF_ROOT_DIR . '/lang/language_' . $LANGCODE . '.php';
} else {
$LANGCODE = 'en';
}

Thorsten
Posts: 14431
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: How to set up the number of categories on the main page

Post by Thorsten » Fri Jun 14, 2013 2:39 pm

Hi,

you don't have to touch code. Login into admin, go to config and change the value there.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

tselyuloza
Posts: 8
Joined: Wed May 29, 2013 8:13 pm

Re: How to set up the number of categories on the main page

Post by tselyuloza » Fri Jun 14, 2013 6:40 pm

so easy, thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest