how to grab prefix list of certain prefix group in template or php page

TBDragon

Active member
hi

i want to know if its possible to grab all prefix of group prefix

like in php page

i wana display all prefix i have on group 1

and when someone click on the prefix it will display all related topics on that prefix

sorry for my english + iam new in xenforo development so i didnt know where to ask :(
 
hi
i just try and try

Code:
$query = "   select prefix_id
    from xf_thread_prefix
    where prefix_group_id = 0";

$sql1 = mysqli_query($mysqli,$query);
$sql2 = "" ;

var_dump($sql1);


echo "<br />";

if($sql1){
while($row = mysqli_fetch_array($sql1,MYSQLI_NUM)){
  //print_r($row[0]." ") ;
    $id = $row[0];
  $sql2 = mysqli_query($mysqli,"select phrase_text
                                      from xf_phrase
                                      where title='thread_prefix_$id'");
}
//echo $sql2;
print_r($sql2);
var_dump($sql2);
mysqli_free_result($sql1);
}

the code should print or display the phrase text of the prefix

when i try the code through

phpmyadmin

for example

Code:
select phrase_text
from xf_phrase
where title='thread_prefix_1';
this query work fine =( and display the text

but dont work with php =_= or i wrote the statements wrong ?
 
i found a stupid solution somehow


first

in ThreadPrefix.php i add this function

Code:
public function getPhraseTBD ($x){
return $results = $this->_getDb()->fetchRow("select phrase_text 
from xf_phrase 
where title=?", $x);
}

then i use
XenForoSdk.php

and add this

Code:
public function getPhraseTBD ($x){
return XenForo_Model::create('XenForo_Model_ThreadPrefix')->getPhraseTBD($x);
}

and on the folder i use
index.php

i put this

Code:
$query = "   select prefix_id
    from xf_thread_prefix
    where prefix_group_id = 0";

$sql1 = mysqli_query($mysqli,$query);
$sql2 = "" ;


var_dump($sql1);


echo "<br />";

if($sql1){
 while($row = mysqli_fetch_array($sql1,MYSQLI_NUM)){
  //print_r($row[0]." ") ;
    $id = $row[0];
    $id2 ="thread_prefix_".$id;
    $y = $sdk->getPhraseTBD($id2);
    echo ($y['phrase_text']);
  //$sql2 = mysqli_query($mysqli,"select phrase_text 
   //                                   from xf_phrase 
   //                                   where title='thread_prefix_$id'");
 }
 //echo $sql2;
 //print_r($sql2);
// var_dump($sql2);
 mysqli_free_result($sql1);
}


some how its display for me the title of the perfix

so is this the right way ? << i dont think that as iam new in this hhh
so i need some comments about the solution O_o

waiting ^_^
 
you ever figure this out?

yes its work for me but not that efficient

1 - i didnt figure out how i can pass the number of a cretin group id
but if i put the number in the php file its work but not from the tempate

2 - i didnt work in the code from 2 month so i forget some thing about i will start work on it again
cuz i have lost the old backup :( and the one i have have some problem and need to be fix

once i fix them i will share it with u
if u want the files that i work one i will send upload them ^^
maybe we can work on them together to find a good solution
 
Top Bottom