mdcpepper / fetch Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I have an interesting issue.
I have a set of about thirty elements and I want to get all of their assets. Each element has 3-5 assets.
This means that over 100 assets will need to be retrieved for my source elements.
However, I'm running into an issue with this code.
$elements = craft()->elements->getCriteria($elementType)
->id($targetIds)
->indexBy('id')
->locale($sourceLocale)
->find();
The limit is not set the criteria model, so it inherits Craft's default limit of 100, which is less than the amount needed in my use case.
The simple thing is to add ->limit(null)
, but I'm not sure what negative effects this could have on usage. I'm thinking that it won't have any effect, since there is no sort of pagination on the related elements. If the performance is slow, then it can be up to the developer to limit the number of source elements.
I don't really think it will be a bad thing to add the null limit, so I'm going to make a pull request to change this. I just wanted to explain it a bit.
Hi I was very happy when find out this plug in, and so much want to work. This plug in work great for categories for me, but I have a problem with assets. When I try to get related assets a get this error:
Undefined offset: 427
/craft/plugins/fetch/services/FetchService.php(72)
I use it like this:
{% set boatBoxs = craft.entries.section('boats').find() %}
{% do craft.fetch.assets(boatBoxs, 'boatGallery') %}
But if I limit the array to 7 entries it work perfect:
{% set boatBoxs = craft.entries.section('boats').limit(7).find() %}
{% do craft.fetch.assets(boatBoxs, 'boatGallery') %}
... if i limit it to 8 it broke again
{% set boatBoxs = craft.entries.section('boats').limit(8).find() %}
{% do craft.fetch.assets(boatBoxs, 'boatGallery') %}
Undefined offset: 4107
.. if i make a offset and limit to to 5, works
{% set boatBoxs = craft.entries.section('boats').offset(7).limit(5).find() %}
{% do craft.fetch.assets(boatBoxs, 'boatGallery') %}
.. if i make a offset and limit to to 6, feil
{% set boatBoxs = craft.entries.section('boats').offset(7).limit(5).find() %}
{% do craft.fetch.assets(boatBoxs, 'boatGallery') %}
Undefined offset: 3902
What can be the problem??? And can this be fixed?
Hi,
I'm not sure how actively this is being developed but I'm running into issues with paginating the query, adding filtering to the query and the fetch plugin.
My current setup is as follows
{% set params = {
section : 'restaurants',
limit: 18,
search : (searchQuery is defined) ? searchQuery
}
%}
{% set query = craft.entries(params) %}
{% if relatedTo | length > 1 %}
{% set query = query.relatedTo(relatedTo) %}
{% endif %}
{% if searchQuery | length %}
{% set query = query.search(searchQuery) %}
{% endif %}
{% do craft.fetch.assets(query.find(), 'images') %}
and my template code
{% paginate query as restaurantList %}
{% for entry in restaurantList %}
{% set image = entry.fetched('images')[0] %}
{{image code }}
{% endfor %}
{{ pagination nav code }}
{% endpaginate %}
Main issue I'm getting is
Craft\EntryModel and its behaviors do not have a method or closure named "fetched".
But only on the /page/n
pages
Hi Mike,
Is there any way to do the following:
{% do craft.fetch.categories(upcomingEvents.find(), 'categories') %}
{% do craft.fetch.assets(upcomingEvents.find(), 'images') %}
It seems the fetched
method will always get overridden by the last craft.fetch.xx
template variable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.