Jump to content

Recommended Posts

Posted

Hey i am trying to perform an OR selector on my Match template

My match template contains 2 fields (pagefields, single) to teams called team_1 and team_2

Now I have the following selector:

$matches = $pages->find("template=match, team_1|team_2=$teams, sort=match_time");

I retrieve the teams as following:

foreach($user->teams as $team)
{
$teams .= $team."|";
}

Above the selector ofcourse. if i echo $teams i get

1011|1014|

And if i run the code i get:

Error Exception: Not unique table/alias: 'field_team_1' (in C:\xampp\htdocs\harmsterproject\wire\core\Database.php line 118)
#0 C:\xampp\htdocs\harmsterproject\wire\core\DatabaseQuery.php(84): Database->query(Object(DatabaseQuerySelect))
#1 C:\xampp\htdocs\harmsterproject\wire\core\PageFinder.php(145): DatabaseQuery->execute()
#2 C:\xampp\htdocs\harmsterproject\wire\core\Pages.php(144): PageFinder->find(Object(Selectors), Array)
#3 [internal function]: Pages->___find('template=match,...')
#4 C:\xampp\htdocs\harmsterproject\wire\core\Wire.php(271): call_user_func_array(Array, Array)
#5 C:\xampp\htdocs\harmsterproject\wire\core\Wire.php(229): Wire->runHooks('find', Array)
#6 C:\xampp\htdocs\harmsterproject\site\templates\dashboard.php(9): Wire->__call('find', Array)
#7 C:\xampp\htdocs\harmsterproject\site\templates\dashboard.php(9): Pages->find('template=match,...')
#8 C:\xampp\htdocs\harmsterproject\site\templates\home.php(3): require_once('C:\xampp\htdocs...')
#9 C:\xampp\htdocs\harmsterproject\wire\core\TemplateF
This error message was shown because you are logged in as a Superuser. Error has been logged.

What is wrong here?

Posted

Hi Harm,

Basically, I think it's that trailing "|" that is the problem. Try building your $teams variable like this...

$teams = implode( "|", $user->teams);

This is untested but might work. If it doesn't then just change the way you build the $teams variable slightly...

foreach($user->teams as $team)
{
 $teams .= $team."|";
}
$teams = rtrim("|", $teams); // pop off that last "|"

Hope that helps.

Posted

Thats... Dissapointing... I kinda really wanted that because i also want to order it by datetime... How can i acchieve something?

Posted

Just joking.... it should work. But take a look again at your error message?

Not unique table/alias: 'field_team_1'

Somethings with wrong with your field, table? I don't know really.

Posted

U scared me Soma D:<

Ehm, no not really i think... It seems okay...

if i just put 1 team in there it works... But multiple doesnt...

  • Like 1
Posted

I just setup something like you mention and it works flawlessly. I have user template with page field to select multiple teams. A team template to create team pages. A match template with two single page fields for tema1 and team2. If I give teams to user and create match pages with teams he is in it gives me the right matches for me.

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...