New answers tagged

2

Type php --ini in your server environment, it should tells you where the .ini files are getting loaded. Then set allow_url_fopen = 1


2

This worked just fine. https://craftcms.stackexchange.com/a/35846/10953 I did all steps execpt steps 3. and 4. Thanks all!


1

You need the url, not the file path. Can you store the url, or the http://localhost:8888 part of it in an environment variable? That gives you $url = getenv('CRAFT_URL') . $id . ".json"; If it is not already in an environment variable, then in a .env file? web/index.php that comes with Craft is a good example of loading a .env file, and then using ...


2

The currentSite property from the Sites service is what you're looking for. Here's how you would use it: 'api/search.json' => function() { $siteHandle = Craft::$app->getSites()->currentSite->handle; ... $criteria = [ 'site' => $siteHandle, ... ]; return [ ... ]; },


2

You could add a new param to the request called skip and use that on your homepage, and default it to zero to allow you to reuse the endpoint elsewhere. $skipEntries = Craft::$app->request->getParam('skip') ?? 0; $criteria = [ 'section' => $settings['section'], 'limit' => $settings['limit'], 'offset' => ($settings['limit'] * ...


2

If you always want to skip the first 6 entries, you can modify the Element API endpoint to add 6 to the offset number in the query criteria: $criteria = [ 'section' => $settings['section'], 'limit' => $settings['limit'], 'offset' => ($settings['limit'] * Craft::$app->request->getParam('offset')) + 6, 'order' => $settings['...


Top 50 recent answers are included