Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

Plug-in JomSocial Article Comments does not work with parent categories

6 years 6 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Selecting category for JomSocial Article Comments is great option, but if parent category is selected comments wont be shown in child categories.

6 years 6 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

I have created an 'ugly' solution but it works. Insert after line 23

$categoryIds =  $this->params->get('category',0);
in ...\plugins\content\articlecomments\articlecomments.php:
foreach ($categoryIds as $categoryId) {
			if (JCategories::getInstance('content')->get($categoryId)->getChildren()){
				foreach (JCategories::getInstance('content')->get($categoryId)->getChildren() as $childrencategory1)
				{
					if (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren()){
						foreach (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren() as $childrencategory2)
						{
							if (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren()){
								foreach (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren() as $childrencategory3)
								{
									if (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren()){
										foreach (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren() as $childrencategory4)
										{
											if (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren()){
												foreach (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren() as $childrencategory5)
												{
													if (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren()){
														foreach (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren() as $childrencategory6)
														{
															if (JCategories::getInstance('content')->get($childrencategory6->id)->getChildren()){

															}
															else {
																if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
															}
														}
													}
													else {
														if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
													}
												}
											}
											else {
												if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
											}
										}
									}
									else {
										if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
									}
								}
							}
							else {
								if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
							}
						}
					}
					else {
						if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
					}
				}
			}
		}
This will add all categories in selected category that have no child categories.
To add all subcategories from selected category you will need to insert this:
foreach ($categoryIds as $categoryId) {
			if (JCategories::getInstance('content')->get($categoryId)->getChildren()){
				foreach (JCategories::getInstance('content')->get($categoryId)->getChildren() as $childrencategory1)
				{
					if (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren()){
						if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
						foreach (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren() as $childrencategory2)
						{
							if (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren()){
								if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
								foreach (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren() as $childrencategory3)
								{
									if (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren()){
										if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
										foreach (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren() as $childrencategory4)
										{
											if (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren()){
												if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
												foreach (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren() as $childrencategory5)
												{
													if (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren()){
														if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
														foreach (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren() as $childrencategory6)
														{
															if (JCategories::getInstance('content')->get($childrencategory6->id)->getChildren()){
																if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
															}
															else {
																if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
															}
														}
													}
													else {
														if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
													}
												}
											}
											else {
												if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
											}
										}
									}
									else {
										if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
									}
								}
							}
							else {
								if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
							}
						}
					}
					else {
						if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
					}
				}
			}
		}

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW