doulai8405 2016-02-21 08:55
浏览 30

too long

I am messing around with the com_content/view/article component. I am trying to add all subdirectories to the class for view.html.php, I can't seem to get the information out of the database. I've been successful at getting The article category and parent category. I tried editing model/article.php I added a loop that would query->select and query->join but I was not sure how to check if the database had more subcategories.

The model gets the article info. uses catID to join the category, then it joins the subcategory and that's it. I want to try and loop through until each subcategory loaded has 0 or null as their parent_id.

The reason why I am doing this is because I want to have opengraph information for each category. In my view.html.php I have a code that sets opengraph description to the article, if there is none in database, it goes to category, if there is none there it loads it from the menu, (not sure if I have that working properly yet), if not then from configuration.php. Well I would like to add in their before menu, subcategories.

Any one have any ideas?

  • 写回答

1条回答 默认 最新

  • doucan4873 2016-02-21 19:51
    关注

    If you have the article category as $catid, this should get all subcategories

    $db = JFactory::getDbo();
    $sql = "select c2.* from #__categories c, #__categories c2
    where c.id={$catid} and c.lft<c2.lft and c2.rgt<c.rgt";
    $db->setQuery($sql);
    $categories = $db->loadObjectList();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大