How to set up the number of categories on the main page
Moderator: Thorsten
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
How to set up the number of categories on the main page
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!
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
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
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
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
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!
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.
Re: How to set up the number of categories on the main page
Hi,
I'll check it for 2.8
bye
Thorsten
I'll check it for 2.8
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
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
Hi,
I'm only working on phpMyFAQ during my free time, it'll take some time
bye
Thorsten
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
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
Hi,
Do you have any update for me?
Do you have any update for me?
Re: How to set up the number of categories on the main page
Hi,
in inc/PMF/Helper/Category.php, line 62
Change
to
I didn't tested that but should work.
bye
Thorsten
in inc/PMF/Helper/Category.php, line 62
Change
Code: Select all
for ($y = 0 ;$y < $numCategories; $y = $this->Category->getNextLineTree($y)) {
Code: Select all
for ($y = 0 ;$y < 10; $y = $this->Category->getNextLineTree($y)) {
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
It works. Thank u a lot!
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
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!
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
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
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
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
"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';
}
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
Hi,
you don't have to touch code. Login into admin, go to config and change the value there.
bye
Thorsten
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
amazon.de Wishlist
-
- Posts: 8
- Joined: Wed May 29, 2013 8:13 pm
Re: How to set up the number of categories on the main page
so easy, thanks!