how to menu item to individual sections?

Phoca Download - download manager
artymarty
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 09 Nov 2008, 02:47
Location: Melbourne, Australia
Contact:

how to menu item to individual sections?

Post by artymarty »

Great module, love it!

I have noticed that the only "menu" option is to go to a LIST of sections.

I see that there have been many requests to add menu options for individual categories and sections.

is there a way for now to 'fudge it' so that I can make an menu item for individual Section?

Marty
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48739
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: how to menu item to individual sections?

Post by Jan »

Hi, this is in feature request list... it is a little bit complicated because of Itemid (e.g. link to sections and link to specifed section will have different Itemid and different settings and there is problem with links - from section to sections, from sestions to section and category - because of different Itemid)

Jan
If you find Phoca extensions useful, please support the project
dax702
Phoca Enthusiast
Phoca Enthusiast
Posts: 85
Joined: 10 May 2008, 21:11

Re: how to menu item to individual sections?

Post by dax702 »

So currently, the only thing the menu item can link to is the section listing?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48739
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: how to menu item to individual sections?

Post by Jan »

yes
If you find Phoca extensions useful, please support the project
Girevik
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 26 Nov 2008, 10:16
Location: Russia, Rybinsk
Contact:

Re: how to menu item to individual sections?

Post by Girevik »

Jan wrote:yes
:cry:
artymarty
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 09 Nov 2008, 02:47
Location: Melbourne, Australia
Contact:

Re: how to menu item to individual sections?

Post by artymarty »

:cry: :x :cry: Perhaps not too far off?
automatikas
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 25 Nov 2008, 15:01

Re: how to menu item to individual sections?

Post by automatikas »

HI there:

I recently solve this by adding the extra variable it to the query:

com_phocadownloads/models/sections.php

Code: Select all

function _getSectionListQuery( $aid, $params ) {
		
		$display_sections = $params->get('display_sections', '');
		if ( $display_sections != '' ) {
			$section_ids_where = " AND s.id IN (".$display_sections.")";
		} else {
			$section_ids_where = '';
		}
		
		$hide_sections = $params->get('hide_sections', '');
		if ( $hide_sections != '' ) {
			$section_ids_not_where = " AND s.id NOT IN (".$hide_sections.")";
		} else {
			$section_ids_not_where = '';
		}
		$groupid = $_GET["group"];
                $wheres[] = " s.gid = $groupid";
		$wheres[] = " s.published = 1";
		$wheres[] = " cc.published = 1";
		$wheres[] = " s.id = cc.section";
Also in the #___downloads DB i inserted an extra field "gid" groupid;

After selecting new menu (external link) to existing component link, you simply add a

Code: Select all

group=(number of the group)

Code: Select all

index.php?option=com_phocadownload&view=sections&group=1
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48739
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: how to menu item to individual sections?

Post by Jan »

ok, great...

Jan
If you find Phoca extensions useful, please support the project
automatikas
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 25 Nov 2008, 15:01

Re: how to menu item to individual sections?

Post by automatikas »

Code: Select all

<?php
/*
 * @package Joomla 1.5
 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 *
 * @component Phoca Component
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport('joomla.application.component.model');


class PhocaDownloadModelSections extends JModel
{
	var $_section 			= null;
	var $_most_viewed_docs 	= null;

	function __construct() {
		parent::__construct();
	}

	function getSectionList($params) {
		$user	=& JFactory::getUser();
		$aid 	= $user->get('aid', 0);	
		
		if (empty($this->_section)) {	
			global $mainframe;
			$user 			= &JFactory::getUser();
			$aid 			= $user->get('aid', 0);			
			$query			= $this->_getSectionListQuery( $aid, $params );
			$this->_section = $this->_getList( $query );
			
			
			if (!empty($this->_section)) {
				foreach ($this->_section as $key => $value) {
					$query	= $this->_getCategoryListQuery( $value->id, $aid, $params );
					$this->_section[$key]->categories = $this->_getList( $query );
				}
			}
			
		}
		return $this->_section;
	}
	
	
	
	
	function _getSectionListQuery( $aid, $params ) {
		
		$display_sections = $params->get('display_sections', '');
		if ( $display_sections != '' ) {
			$section_ids_where = " AND s.id IN (".$display_sections.")";
		} else {
			$section_ids_where = '';
		}
		
		$hide_sections = $params->get('hide_sections', '');
		if ( $hide_sections != '' ) {
			$section_ids_not_where = " AND s.id NOT IN (".$hide_sections.")";
		} else {
			$section_ids_not_where = '';
		}
		$tarpine = $_GET["group"];
		if ( $tarpine != 'all' ) {
			$wheres[] = " s.gid = $tarpine";
		} else {
			$wheres[] = " s.all = 0";
		}
		$wheres[] = " s.published = 1";
		$wheres[] = " cc.published = 1";
		$wheres[] = " s.id = cc.section";
			

		if ($aid !== null) {
			$wheres[] = "s.access <= " . (int) $aid;
		}
		

		$query =  " SELECT s.id, s.title, s.alias, s.gid, s.all, COUNT(cc.id) AS numcat, '' AS categories"
				. " FROM #__phocadownload_sections AS s, #__phocadownload_categories AS cc"
				. " WHERE " . implode( " AND ", $wheres )
				. $section_ids_where
				. $section_ids_not_where
				. " GROUP BY s.id"
				. " ORDER BY s.ordering";
		return $query;
	}
	
	
	function _getCategoryListQuery( $sectionId, $aid, $params ) {
		
		$wheres[]	= " cc.section= ".(int)$sectionId;
		if ($aid !== null) {
			$wheres[] = "cc.access <= " . (int) $aid;
		}
		$wheres[] = " cc.published = 1";
		
		$query = " SELECT  cc.id, cc.title, cc.alias, COUNT(c.id) AS numdoc"
				. " FROM #__phocadownload_categories AS cc"
				. " LEFT JOIN #__phocadownload AS c ON c.catid = cc.id AND c.published = 1"
				. " WHERE " . implode( " AND ", $wheres )
				. " GROUP BY cc.id"
				. " ORDER BY cc.ordering";
				
		return $query;
		
		
	}
	
	function getMostViewedDocsList($params) {
		$user	=& JFactory::getUser();
		$aid 	= $user->get('aid', 0);	
		
		if (empty($this->_most_viewed_docs)) {	
			global $mainframe;
			$user 						= &JFactory::getUser();
			$aid 						= $user->get('aid', 0);			
			$query						= $this->_getMostViewedDocsListQuery( $aid, $params );
			$this->_most_viewed_docs 	= $this->_getList( $query );
		}
		return $this->_most_viewed_docs;
	}
	
	function _getMostViewedDocsListQuery( $aid, $params ) {
		
		// PARAMS
		$most_viewed_docs_num = $params->get( 'most_viewed_docs_num', 5 );
		
		$display_sections = $params->get('display_sections', '');
		if ( $display_sections != '' ) {
			$section_ids_where = " AND s.id IN (".$display_sections.")";
		} else {
			$section_ids_where = '';
		}
		
		$hide_sections = $params->get('hide_sections', '');
		if ( $hide_sections != '' ) {
			$section_ids_not_where = " AND s.id NOT IN (".$hide_sections.")";
		} else {
			$section_ids_not_where = '';
		}
		
		$wheres[]	= " c.sectionid= s.id";
		$wheres[]	= " c.catid= cc.id";
		$wheres[]	= " c.published= 1";
		$wheres[]	= " c.textonly= 0";
		if ($aid !== null) {
			$wheres[] = "c.access <= " . (int) $aid;
			$wheres[] = "s.access <= " . (int) $aid;
			$wheres[] = "cc.access <= " . (int) $aid;
		}
		
		$query = " SELECT c.id, c.title,  c.alias, c.filename, c.date, c.hits, c.image_filename, s.title AS sectiontitle, cc.id AS categoryid, cc.title AS categorytitle, cc.alias AS categoryalias "
				." FROM #__phocadownload AS c, #__phocadownload_sections AS s, #__phocadownload_categories AS cc"
				. " WHERE " . implode( " AND ", $wheres )
				. $section_ids_where
				. $section_ids_not_where
				. " ORDER BY c.hits DESC"
				. " LIMIT ".(int)$most_viewed_docs_num;
		return $query;
	}
}
?>
wolwes
Phoca Member
Phoca Member
Posts: 10
Joined: 29 Dec 2008, 13:51

Re: how to menu item to individual sections?

Post by wolwes »

Hallo,
exuse me, but I can't describe this in English...

Also, die vorgestellte Lösung von automaticas funktioniert nicht. Ich weiß auch nicht, wie das Feld "all" gehandelt werden soll.

Ich habe aber eine Lösung gefunden, basierend auf automaticas Vorschlag.

Hier die einzelnen Schritte:

In MySQL mit phpMyAdmin in der Tabelle jos_phocadownloads_sections ein neues Feld "gid" - Typ: int errichten, dann diese Spalte ausfüllen mit den gleichen Werten aus der Spalte "id". Aufschreiben, welche gid-nummer für welche Section zuständig ist.

Nun öffnen wir die Datei \Joomla\components\com_phocadownload\models\sections.php (die mit dem "s" am Ende!) und nehmen dort eine Änderung vor. Nur die Function _getsectionListQuery(....) ist von Interesse:

Code: Select all

function _getSectionListQuery( $aid, $params ) {

                $display_sections = $params->get('display_sections', '');
                if ( $display_sections != '' ) {
                        $section_ids_where = " AND s.id IN (".$display_sections.")";
                } else {
                        $section_ids_where = '';
                }

                $hide_sections = $params->get('hide_sections', '');
                if ( $hide_sections != '' ) {
                        $section_ids_not_where = " AND s.id NOT IN (".$hide_sections.")";
                } else {
                        $section_ids_not_where = '';
                }


                 $GruppenID = $_GET["group"];

                $wheres[] = " s.published = 1";
                $wheres[] = " cc.published = 1";

               if ( $GruppenID != 0 ) {
                  $wheres[] = " s.gid = $GruppenID";
                 $wheres[] = " s.gid = cc.section";
                  $Gruppieren=" GROUP BY s.gid";
               } else {
                  $wheres[] = " s.id = cc.section";
                  $Gruppieren=" GROUP BY s.id";
               }

                if ($aid !== null) {
                        $wheres[] = "s.access <= " . (int) $aid;
                }


                $query =  " SELECT s.id, s.title, s.alias, COUNT(cc.id) AS numcat, '' AS categories"
                                . " FROM #__phocadownload_sections AS s, #__phocadownload_categories AS cc"
                                . " WHERE " . implode( " AND ", $wheres )
                                . $section_ids_where
                                . $section_ids_not_where
                                . $Gruppieren
                                . " ORDER BY s.ordering";
                return $query;
        }
Bitte beim Ändern peinlich genau auf alle Zeichen achten! Am Besten kopiert man die gesamte Function von oben komplett in genannte Datei und überschreibt die "alte" Function in der Datei.

Die Datei nun speichern.

Nun gehen wir ins Backend und rufen dort den Punkt Menüs auf und darin das Menü, in dem die Phocadownloads Menüs sind. Da ändern wir den Typ

auf Externen Link. (Achtung, das Menü muss vorher schon mit dem normalen Phocadownload-Typ verlinkt gewesen sein, damit nun nach dem Umbiegen auf den externen Link das Feld für den Link ausgefüllt ist!

In dem Linkfeld fügen wir nun ans Ende - ohne Leerzeichen - &group=1 oder eine andere Zahl, je nach Section. Der Link könnte dann so etwa aussehen: index.php?option=com_phocadownload&view=sections&group=1

Jetzt wird nach Neuladen der Webseite nur noch die passende Sektion erscheinen.

Wenn man es so haben will, wie vorher - alle Sections - trägt man group=0 ein!

Ich finde die Komponente sehr gut und danke den "Machern" auf diesem Wege und hoffe, dass irgendwann einmal die Darstellung der einzelnen Sections offiziell eingebaut wird, so dass man das Ganze auch vom Backend aus einstellen kann.

Grüße
Wolfgang

PS: Wenn ich EOF, also die Suchmaschinenoptimierung einschalte - und nur die, kein htaccess usw - gehts bei mir mit meinem Qnap Server nicht mehr! Wahrscheinlich erkennt die $_get Variable die Group ID nicht mehr, weil nun direkt vor group=1 ein "/" steht? Ich weiß es nicht...
Post Reply