×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Need Help contentid stay at 0 all the time

Need Help contentid stay at 0 all the time 14 years 5 months ago #7598

  • joel
  • joel's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hello Daniel,

I have created a component name com_dojo

My main difference is that the ID of my content is name cf_id and not id

I use josc_com_mmsblog.class.php as a base to start.

in the file josc_com_mmsblog.class.php you have a lot of ID word and I not sure exactly if the are from my table or from comment or from categories tables.

could you identify where my cf_id should replace id in this file.

all my page show all the comment and all the new comment posted receive the contentid 0 and not the cf_id.

PS: I have it to work, but if I change the contentid manualy to the right cf_id in the admin side the ContentItem show the right thing (Name).

Thanks for you help

Need Help contentid stay at 0 all the time 14 years 5 months ago #7603

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I responded to your e-mail. As I said, if your id is cf_id , then you should use
JRequest::getVar('cf_id') to read it.

Need Help contentid stay at 0 all the time 14 years 5 months ago #7621

  • joel
  • joel's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Thanks again for you valuble help

here is my Url for a page

?option=com_dojo&task=view&cid[0]=4&Itemid=56

&cid[0]=4 is the page link but in the table the field that have the page id is cf_id

Could you confirm that this is good at the top of my josc_com_dojo.class.php file I have change this

function __construct($component,&$row,&$list) {
$id= isset($row->cf_id) ? $row->cf_id : 0; /* document id */
$this->id = $id;

Joel

Need Help contentid stay at 0 all the time 14 years 5 months ago #7622

  • joel
  • joel's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hello If that could help here is my class file

PS: I am not using any section or categories thanks...


class JOSC_com_dojo extends JOSC_component {

function __construct($component,&$row,&$list) {
$id = isset($row->cf_id) ? $row->cf_id : 0; /* document id */
$this->id = $id;

$this->setRowDatas($row); /* get specific properties */

$this->JOSC_component($component,0,$id);
}

/*
* Set specific properties
* will be called also in admin.html.php manage comments during row loop
*/
function setRowDatas(&$row) {
/* for optimization reason, do not save row. save just needed parameters */
}

function getPageId() {
return $this->id;
}

function createFeed() {
require_once(JPATH_SITE."/includes/feedcreator.class.php");
$contentid = JOSC_utils::decodeData('contentid');
$component = 'com_dojo';

$database = JFactory::getDBO();
$database->setQuery("SELECT nom, prenom FROM jos_les_ames WHERE cf_id='$contentid'");
$content = $database->loadObject();
$rss = new UniversalFeedCreator();
$rss->useCached("RSS2.0", JPATH_SITE. DS .'components'.DS. 'com_comment'.DS.'dojofeed.xml');
$rss->title = $content->subject. ' - comments' ;
$rss->description = $content->content;
$rss->link = JURI :: base();


$database->setQuery("SELECT *,UNIX_TIMESTAMP( date ) AS rss_date FROM jos_comment WHERE contentid='$contentid' AND component='$component' AND published='1' ORDER BY id ASC", '', 100);
$data = $database->loadAssocList();
if ($data != null) {
foreach($data as $item) {
$rss_item = new FeedItem();
$rss_item->author = $item;
if(strcmp($item,'')) {
$rss_item->title = $item;
}else {
$rss_item->title = 'no comment title';
}
$rss_item->link = $this->linkToContent($contentid, $item);
$rss_item->description = $item;
$rss_item->date = date('r', $item);
$rss->addItem($rss_item);
}
}
$rss->cssStyleSheet = " www.w3.org/2000/08/w3c-synd/style.css ";
$rss->saveFeed("RSS2.0", JPATH_SITE. DS .'components'.DS. 'com_comment'.DS.'joscfeed.xml');
}
/*
* This function is executed to check
* if section/category of the row are authorized or not (exclude/include from the setting)
* return : true for authorized / false for excluded
*/
function checkSectionCategory(&$row, $include, $sections=array(), $catids=array(), $contentids=array()) {
/* doc id excluded ? */
if (in_array((($row->id == 0) ? -1 : $row->id), $contentids))
return false;

/* category included or excluded ? */

$dojo_catid = $this->getMMSCatId($row->prive);

$result = in_array((($dojo_catid->id == 0) ? -1 : $dojo_catid->id), $catids);

if (($include && !$result) || (!$include && $result)) {
return false; /* include and not found OR exclude and found */
}
return true;
}

/*
* Condition to active or not the display of the post and input form
* If the return is false, show readon will be executed.
*/
function checkVisual($contentId=0) {
$option = JRequest::getCMD('option');
$view = JRequest::getVar('view' );

return ( $option == 'com_dojo'
&& $view == 'page'
);
}

/*
* This function will active or deactivate the show readon display
*/
function setShowReadon( &$row, &$params, &$config ) {
$show_readon = $config->_show_readon;

return $show_readon;
}

/*
* construct the link to the content item
* (and also direct to the comment if commentId set)
*/
function linkToContent($contentId, $commentId='', $joscclean=false, $admin=false) {
$appl =& JFactory::getApplication();

$add = ( $joscclean ? "&joscclean=1" : "" ) . ( $commentId ? "&comment_id=$commentId#josc$commentId" : "" ) ;

if($appl->scope == 'mod_comments') {
$mod_data = $this->getAliasMod($contentId);
$contentId = $contentId . '-' . $mod_data->alias;
}

$url = JRoute::_(JURI::root().'index.php?option=com_dojo&task=view&cid[0]=' . $contentId . $add);

return ($url);
}

/*
* clean the cache of the component when comments are inserted/modified...
* (if cache is active)
*/
function cleanComponentCache() {
$cache =& JFactory::getCache('com_dojo');
$cache->clean('com_dojo');
}


/*
* F U N C T I O N S F O R A D M I N P A R T
*
*/

/*
* section option list used to display the include/exclude section list in setting
* must return an array of objects (id,title)
*/
function getSectionsIdOption() {
$database =& JFactory::getDBO();

$sectoptions = array();

return $sectoptions;
}

/*
* categories option list used to display the include/exclude category list in setting
* must return an array of objects (id,title)
*/
function getCategoriesIdOption() {
$database =& JFactory::getDBO();

$catoptions = array();
$query = "SELECT id, title"
. "\n FROM jos_categories"
. "\n WHERE published = 1"
//. "\n AND section = 'com_dojo' "
// . "\n AND access >= 0"
. "\n ORDER BY ordering"
;
$database->setQuery( $query );
$catoptions = $database->loadObjectList();
return $catoptions;
}

/*
* document list (or single) for new and edit comment
* must return an array of objects (id,title)
*/
function getObjectIdOption($id=0, $select=true) {
$database =& JFactory::getDBO();

$content = array();
$query = "SELECT cf_id, nom AS title"
. "\n FROM jos_les_ames "
. " WHERE published=1"
. ($id ? "\n AND cf_id = $id":"")
;
$database->setQuery( $query );
$content = $database->loadObjectList();
if (!$id && $select && count($content)>0) {
array_unshift( $content, mosHTML::makeOption( '0', '-- Select DoJo Item --', 'cf_id', 'title' ) );
}

return $content;
}
function getViewTitleField() {
$title = 'nom';
return($title);
}
function getViewJoinQuery($alias, $contentid) {
$leftjoin = "\n LEFT JOIN jos_les_ames AS $alias ON $alias.cf_id = $contentid ";
return $leftjoin;
}

/*
* F U N C T I O N S F O R MOD_COMMENTS M O D U L E
*
*/
function mod_commentsGetMostCommentedQuery($secids, $catids, $maxlines) {
$database =& JFactory::getDBO();

$component = $this->_component;

$limit = $maxlines>=0 ? " limit $maxlines " : "";

$where = array();
if ($secids)
$where[] = "cat.id IN ($secids)";

/*
* Count comment id group by contentid
* TODO: restrict according to user rights, dates and category/secitons published and dates...
*/
$query = "SELECT COUNT(c.id) AS countid, , ct.nom AS title "
. "\n FROM `vpo_comment` AS c "
. "\n INNER JOIN `vpo_les_ames` AS ct ON ct.cf_id = c.contentid "
. "\n WHERE c.published='1' "
. "\n AND c.component='$component' "
. "\n ". (count($where) ? (" AND ".implode(" AND ", $where)) : "")
. "\n GROUP BY c.contentid"
. "\n ORDER BY countid DESC"
. "\n $limit"
;
$database->SetQuery($query);
$rows = $database->loadAssocList();

return $rows;
}

function mod_commentsGetOthersQuery($secids, $catids, $maxlines, $orderby) {
$database =& JFactory::getDBO();

$component = $this->_component;

$limit = $maxlines>=0 ? " limit $maxlines " : "";

$where = array();
if ($secids)
$where[] = "cat.id IN ($secids)";

if ($orderby=='mostrated') {
$mostrated = ", (c.voting_yes-c.voting_no)/2 AS mostrated";
$where[] = "(c.voting_yes > 0 OR c.voting_no > 0)";
} else {
$mostrated = "";
$orderby = "c.$orderby";
}

/*
* TODO: restrict according to user rights, dates and category/secitons published and dates...
*/
$query = "SELECT c.*, ct.nom AS ctitle $mostrated "
. "\n FROM `vpo_comment` AS c "
. "\n INNER JOIN `vpo_les_ames` as ct ON ct.cf_id = c.contentid "
. "\n WHERE c.published='1' "
. "\n AND c.component='$component' "
. "\n ". (count($where) ? (" AND ".implode(" AND ", $where)) : "")
. "\n ORDER BY $orderby DESC "
. "\n $limit"
;
$database->SetQuery($query);
$rows = $database->loadAssocList();

return $rows;
}

/*
* O P T I O N N A L
* F O R E X P E R T M O D E O N L Y
* not yet available.
* do not report theses functions !
*/
/*
* section option list for the admin setting
*/
function getExpertSectionIdOption($sections, $include) {
$database =& JFactory::getDBO();

$where = "";
if ($sections) {
if ($include)
$where = "\n AND id IN ($sections) ";
else
$where = "\n AND id NOT IN ($sections) ";
}
$sectoptions = array();
$query = "SELECT id, title"
. "\n FROM jos_categories"
. "\n WHERE published = 1"
//. "\n AND section = 'com_dojo' "
. $where
// . "\n AND access >= 0"
. "\n ORDER BY ordering"
;
$database->setQuery( $query );
$sectoptions = $database->loadObjectList();
// add "All sections"
array_unshift( $sectoptions, JHTML::_('select.option', '0', '-- All --', 'id', 'title' ) );

return $sectoptions;
}
/*
* @var $contentid int
* @return sectionid, categoryid, alias
*/
function getAliasMod($contentid) {
$database =& JFactory::getDBO();
$query = 'SELECT alias '
. ' FROM ' . $database->nameQuote('jos_les_ames')
. ' WHERE cf_id = ' . $database->Quote($contentid)
;
$database->setQuery($query, '', 1);
$row = $database->loadObject();
return $row;
}

/*
* return the id,title section object
*/
function getExpertSectionTitle($sectionid) {
$database =& JFactory::getDBO();

if ($sectionid==0)
return '(0) All ';

$query = "SELECT id, title"
. "\n FROM jos_categories"
. "\n WHERE id=$sectionid"
;
$database->setQuery( $query );
$row = $database->loadObjectList();
return "($sectionid) ".$row[0]->title;
}

function getMMSCatId($cat_name) {
$database =& JFactory::getDBO();
$query = ' SELECT id '
. ' FROM ' . $database->nameQuote('jos_categories')
. ' WHERE title = ' . $database->Quote($cat_name);
$database->setQuery($query);
$row = $database->loadObject();

return $row;
}
}

Need Help contentid stay at 0 all the time 14 years 5 months ago #7624

  • joel
  • joel's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hello Daniel

It look like it is working now with this code



function __construct($component,&$row,&$list) {
global $mainframe, $option;
global $mainframe;
$array = JRequest::getVar('cid', 0, '', 'array');
$this->setId((int)$array[0]);
$id = $this->_id;
$this->setRowDatas($row); /* get specific properties */
$this->JOSC_component($component,0,$id);
}
function setId($id)
{
// Set id and wipe data
$this->_id = $id;
$this->_data = null;
}


Last thing (for now!) do you know why the editor is allways open, you know when there is no comment it is nomally showing one a line and the editor is close and if you click on the line the editor is opening for you to insert your comment. My editor is allways open.

Any solution?

Thanks

Need Help contentid stay at 0 all the time 14 years 5 months ago #7626

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
change the template to one of the MT....

I'm happy that it is working, but you will have to clean up the code a little bit.

For example you haee a global $mainframe and $option, but you don't use them anywhere :)

Need Help contentid stay at 0 all the time 14 years 5 months ago #7634

  • joel
  • joel's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Thank you very much!!


I have found what I need in the HTML file of the JQdefault-emotop template.

it is working with a script to show and hide the Wirte comment block.

I copy the script in the modern Template et Voilà!!!

Thanks again for all your help
  • Page:
  • 1
Time to create page: 0.123 seconds