Widget:NewsLanding/LatestNews/Category

From TwogPedia

<script> function changeCategory(e, newCat) {

 var parameters = ;
 var list = document.querySelector(".news-latest")
 if ( !list ) return
 var category = list.dataset.category;
 if ( newCat === category ) return
 // Use the selected template as a parameter in the parser function
 var parserFunction = "Lua error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+ newCat + ""  ORDER BY `date` DESC LIMIT 4' at line 1

Function: CargoSQLQuery::run Query: SELECT `_pageName` AS `_pageName`,`date` AS `date`,`image` AS `image`,`category__full` AS `category`,`game__full` AS `game`,`content` AS `content`,`date__precision` AS `date__precision` FROM `wiki_cargo__News` WHERE `wiki_cargo__News`.`_ID` IN ( SELECT DISTINCT( `_rowID` ) FROM `wiki_cargo__News__category` WHERE `_value` IN ( SELECT `_value` FROM `wiki_cargo__News__category__hierarchy` WHERE `_left` >= ( SELECT `_left` FROM `wiki_cargo__News__category__hierarchy` WHERE `_value` = "" ) AND `_right` <= ( SELECT `_right` FROM `wiki_cargo__News__category__hierarchy` WHERE `_value` = "" ) ) ) + newCat + "" ORDER BY `date` DESC LIMIT 4 .";

 // Replace the content in the dynamic content container with the parsed template
 $.get(mw.util.wikiScript('api'), { action: 'parse', format: 'json', text: parserFunction }, function(data) {
   var parsedContent = data.parse.text['*'];
   
   var content = document.createElement('div')
   content.innerHTML = parsedContent
   if ( content.querySelector('.mw-parser-output div') ) {
      list.innerHTML = content.querySelector('.mw-parser-output').innerHTML;
      list.dataset.offset = 4
      list.dataset.category = newCat
      document.querySelector('.active-cat')?.classList.remove('active-cat')
      e.target.classList.add('active-cat')
      
   }
 });

} </script>

Transfer Market
Drama
Business
Sponsorships
More