Page 1 of 1

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

Posted: Wed May 29, 2013 8:40 pm
by tselyuloza
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!

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

Posted: Thu May 30, 2013 7:20 pm
by Thorsten
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

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

Posted: Thu May 30, 2013 8:25 pm
by tselyuloza
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!

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

Posted: Fri May 31, 2013 6:21 am
by Thorsten
Hi,

I'll check it for 2.8

bye
Thorsten

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

Posted: Fri May 31, 2013 10:55 am
by tselyuloza
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 ;-)

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

Posted: Fri May 31, 2013 11:36 am
by Thorsten
Hi,

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

bye
Thorsten

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

Posted: Mon Jun 10, 2013 2:11 pm
by tselyuloza
Hi,

Do you have any update for me? ;)

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

Posted: Wed Jun 12, 2013 8:54 pm
by Thorsten
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

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

Posted: Thu Jun 13, 2013 1:28 pm
by tselyuloza
It works. Thank u a lot!

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

Posted: Fri Jun 14, 2013 1:02 pm
by tselyuloza
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!

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

Posted: Fri Jun 14, 2013 1:13 pm
by Thorsten
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

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

Posted: Fri Jun 14, 2013 2:14 pm
by tselyuloza
"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';
}

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

Posted: Fri Jun 14, 2013 2:39 pm
by Thorsten
Hi,

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

bye
Thorsten

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

Posted: Fri Jun 14, 2013 6:40 pm
by tselyuloza
so easy, thanks!