Harmster Posted December 11, 2012 Share Posted December 11, 2012 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? Link to comment Share on other sites More sharing options...
netcarver Posted December 11, 2012 Share Posted December 11, 2012 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. Link to comment Share on other sites More sharing options...
Harmster Posted December 11, 2012 Author Share Posted December 11, 2012 Both examples do not work, Maybe I should of told that the teams is a pagearray field aswell but it contains more pages... Link to comment Share on other sites More sharing options...
Soma Posted December 11, 2012 Share Posted December 11, 2012 There's no support for team_1|team_2=1011|1014| Link to comment Share on other sites More sharing options...
Harmster Posted December 11, 2012 Author Share Posted December 11, 2012 Thats... Dissapointing... I kinda really wanted that because i also want to order it by datetime... How can i acchieve something? Link to comment Share on other sites More sharing options...
Soma Posted December 11, 2012 Share Posted December 11, 2012 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. Link to comment Share on other sites More sharing options...
Harmster Posted December 11, 2012 Author Share Posted December 11, 2012 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... 1 Link to comment Share on other sites More sharing options...
Soma Posted December 11, 2012 Share Posted December 11, 2012 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. 1 Link to comment Share on other sites More sharing options...
Harmster Posted December 11, 2012 Author Share Posted December 11, 2012 And what is the code you used to display the matches? Link to comment Share on other sites More sharing options...
Soma Posted December 11, 2012 Share Posted December 11, 2012 echo "found: ".$pages->find("template=match, team_1|team_2=$user->teams"); 1 Link to comment Share on other sites More sharing options...
Harmster Posted December 11, 2012 Author Share Posted December 11, 2012 Ok that did work for some reason... Thanks Soma Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now