Recently Browsing 0 members
No registered users viewing this page.
Still in my 'teaching game'. Here's my problem : I 'find' all players with a request like
$allPlayers = $pages->find("template=player"); [/code Then, I limit to players belonging to the team of the logged in player with [code] $teamPlayers = $allPlayers->find("team=$loggedPlayer->team");
No problem so far. But my scoreboards rely on either :
to find the logged player's position in the charts.
On the 'global' newboard with scoreboards based upon $allPlayers, everything works as expected.
BUT on my 'team' newsboard, even though I'm using $teamPlayers, the returned indexes are based upon $allPlayers. Am I clear ? In other words, I have a total of 125 players, and my logged player is 61 out of 125 regarding the number of places he freed. But in his particular team of 25 players, he sould be 15 whereas he's still 61
I'd like to reset my indexes (and start back from 0), but I can't find my way out of this...
If someone has a hint to help, I'd appreciate.
I have a second part in my worry : I had a way around it by simply making another 'raw' request :
$teamPlayers = $pages->find("team=$loggedPlayer->team");
Then my team indexes were right, but I faced another issue : Reordering my wirearray according to the scoreboard I want usually worked fine (simple sort() based upon an integer field, for example, player's coins, player's karma...) and indexes were updated BUT resorting with places.count ('places' field is a pageArray) doesn't update the indexes returned by getItemKey and my logged player is always at the position he was when I first did my initial $pages->find() query
So my way around found its limit and that's why I'm posting here, after struggling with this for a couple of hours...
Thanks in advance for the help.
I am using ProcessWire as the back-end to manage contents on multiple sites (I call them "sub-domains"). I use ProcessWire as an editing system and database only. The ProcessWire templating system is not in use. I want to use ProcessWire's API and in particular the Include & Bootstrap method to output contents -- pretty much in the same way you do, if contents is stored in a MySQL database and output in PHP files that use PDO to load data.
The issue is that I cannot get ProcessWire to fully work on each of the "sub-domains".
> You can do anything with ProcessWire's API that you can do from a template,
> so all of this still applies, as does everything in the developer API.
How can I get access to variables such as $input when using Include & Bootstrap?
I tried these:
$wire->pages->get("/foo/bar/"); echo "Segment1: " . $wire->input->urlSegment1; # Returns null $wire->pages->get("/foo/bar/"); echo "Segment1: " . $wire->input()->urlSegment1; # Internal Server Error $p = $wire->pages->get("/foo/bar/"); echo "Segment1: " . $p->input->urlSegment1; # Returns null $p = $wire->pages->get("/foo/bar/"); echo "Segment1: " . $p->input()->urlSegment1; # Returns null @ryan Can the API Variables documentation be updated with a section / an example that explain how to use "Include & Bootstrap" for each variable (since this is a really strong feature in ProcessWire)?
$page $pages - Example: $homepage = $wire->pages->get("/"); $input $sanitizer $session $fields $user $log $templates $config
I'm trying to limit a specific user can only add pages as a child (under) a page created by themselves.
The discussion in this thread gets close, it's a working solution on how to only allow editing on pages you created yourself. I'm using this and it works well. But I'm not sure how to modify this for my purposes.
I'm suspecting I need to do to something like
$this->addHookBefore("Page::added", $this, 'added');
then in "added" check if parent is created by the current user. But I'm a bit lost on how exactly to do this.
thank you! /J
Maybe I'm missing something here, but I'm haveing a hard time to get absolute urls if PW is installed in a subdirectory thought the API...
I need an absolute URL for the backend (as a redirect url of Oauth provider). To build the url i would normaly use
url()->root.url()->admin – but this results in the install-path beeing present twice;
domain.com/path/ + path/admin/
In order to not use $_SERVER['HTTP_HOST'] I fetch the admin page from pages – but this is also not to easy since I need to remove the root folder from path as well. My current solution is somewhat complicated:
$backendUrl = pages()->get('path="'.str_replace(urls()->root, '', urls()->admin).'", include=all')->httpUrl; The above code seems to be the savest way to get the absolute url to the backend using pure PW API, am I right?
It would be great if one could fetch absolute urls with something like this
$backendUrl = urls()->admin->httpUrl // or $backendUrl = httpUrls()->admin
Thank you @adrian – of course this HAD to be simpler:
Sometimes I need pages in the site tree that are basically just a reference to another page – to redirect to the original page or display the same content under the new page url.
I was surprised I couldn't find anything like that in the forum or as a module already. However, there is a new module by @Robin S but not exactly what I need.
Home News Press Newsroom Media Services About Newsroom (virtual page for /news/newsroom/) Contact Example I: The page /about/newsroom/ should act as /news/newsroom/ – so, wehen I loop all pages for a sitemap both pages should have the URL /news/newsroom/.
Example II: Another example (not often used) would be tu display the exact same content on /about/newsroom/ – although the page itself has no content on its own.
Those examples don't have much in common, but they are just virtual or fake pages in the site tree.
While the second one should be an easy task with wireRenderFile(), the first example isn't quite obvious to me. I think I have to use hooks and I have no idea where to start. I really appreciate you guys come up with a solution for everything, but I need to learn this myself So just some hints to start would be great!
Do I put the code into a module or some of the _init.php, ready.php etc. files? Or do I have to use a template file (e.g. virtual-page.php)? When I look into Captain Hook – how do I find the appropriate point to hook into? (/wire/core/ Page.php and loaded()?) Do I need to create/manipulate each field separately (path, title, summary)? Sorry for the long read