Doctrine QueryBuilder custom field, constructed from two different - symfony

I've searching for the solution to my problem, I wouldn't call it a problem, but I just can't find any documentation.
Basically what I want to do is:
I have two entities: Gallery & PhotoItem
PhotoItem has these fields: id, image, updatedAt
image field holds the name of the photo item with its extension.
When I get certain Gallery with joins to PhotoItem. I would also like to get additional field, which would be a CONCAT of %certain.parameter.with.baseurl.of.website% and the image field. So my API would return full path to the asset.
Is it possible to do it in QueryBuilder? Because right now I would loop through elements in PHP and add additional property.

Related

Use the unique values from a field in one content type as a filter in another content type

I need some help with a Drupal views filter. I'm not a developer but I have been using Drupal for several years.
I have a content type named 'City/Town' that contains several fields including state and county. I'm using this content type as an entity reference field in another content type named 'Project'.
I would like to use a unique value list of States as a filter in a view of Projects.
I've installed the Views Entity Reference Filter (https://www.drupal.org/project/verf) module but I'm only able to access the entity reference title, not any of the fields that are part of the content type.
The project I'm working on is still in design phase so I can change my approach if there is a viable solution.
You need to get the relationship to the reference in views. Then you have access to the fields of the reference for viewing, sorting & filtering.

How do I get the location field to show anything in plone-4.x collections

I am trying to use a collection that will list items by state and provide a link to them in the location field of a table listing. The reason the location is important is that the same item can be added to lots of different folders/objects, so the title and type is not informative enough. Anyway, my problem is that the location gives a blank entry in the table displaying the collection. I have tried this for all types of items on my site: pages, folders, custom dexterity content types, etc.. Any hints?
Present configuration is Plone-4.3
Thanks.
The "location" field you are using is probably the ones only populated by the Event content type (please, check it).
If I'm not wrong, you can:
add a new index to the catalog that index the getLocation attribute, that will load the "Location" metadata; then add a new collection configuration for loading this new metadata
add a new indexer that will load the getLocation information using the same "location"
The 1 is the easy way (probably you can do all TTW) but way 2 is cleaner (but require some development)

getting all ImageFields associated with a node

How do i get all the image fields attached to a content type on a full node without knowing the field names? Just out of curiosity, is there a way we can get all the fields of a specific type?
I am developing a module that needs image fields tied to a specific node and i'm using hook_node_view for fetching the node data.
I already viewed following post and it seems pretty relevant but i had difficulty understanding.
How to get the first image field from a node without knowing the field's name?
This can be done by checking all the fields of your content type & check its "type" field
if the type field is a image you can render it
Well, i finally found the function i was looking for and it was pretty simple. All i had to do was to get all the fields field_info_instances() with $entity_type as the first parameter and then iterating over the result to get the widget type 'image_image' for ImageFields.

Wordpress: Creating a thorough custom post type for recipes

I am currently trying to create a custom post type for recipes. My goal is to include the schema.org/Recipe and or hrecipe microformat and also have the ability to filter for ingredients in the future.
To do this I intend to have an interface with fields for title, photo, description, ingredients and instructions.
My question is: Should I create separate fields for each ingredient and each amount? Or would you say it is sufficient to just create one field for all ingredients? (also keeping the aforementioned microformats in mind).
http://schema.org/Recipe
http://microformats.org/wiki/hrecipe
Having ingredients as a single field is what is expected in both formats you linked to. Querying / filtering based on ingredient name will be slightly more complex...but you should be able to handle it.
There are 3 parts to this answer.
How should you save ingredients in WordPress
How should you allow users to modify the ingredients list
How should you display ingredients publicly
For point 1, you will have to give a bit of thought as to how you save the ingredient list and how you retrieve/display it along with how it is queried. One of the formats indicate you could have properties for each ingredient (still in draft).
You could save an ingredient list as a serialized PHP array, something like this:
$ingredients[]=array('milk','value'=>'125','type'=>'ml');
$ingredients[]=array('sugar','value'=>'1','type'=>'cup');
Since serialized PHP arrays are standardized, you could fairly easily write an WP query that takes it into account.
Keep in mind you will want to have a plan for when the 'value' and 'type' modifiers are set in stone and how to migrate what you saved if they are different.
For point 2, you could create a custom meta box that deserializes the PHP array saved and render individual controls for each ingredient along with controls to allow management (Add, Deletes, Updates).
For point 3....the easiest would be to get the value and manipulate it how you want in the output.

Drupal: Display only specific NodeReferrer field in Views

I have a content type appointment with a date field that references nodes of the content type person using the Nodereference module. In the content type person I added a Nodereferrer field that shows the reverse of this references (Person -> appointments).
I now want to create a view of person nodes that shows the last appointment date of that person. I can create a View of persons with a relationship to appointments that displays all appointments, but I have no idea on how to display only the most recent one.
Any ideas on how to achieve this?
Personally I have not had much success with using views and node reference. It never seems to work out the relationships properly.
So my advice would be to write your own query. If you look here you can see a way to override the SQL generated by views, so you still get a lot of the goodness which comes with views.
By the way I would be very interest to see if there is a better answer than this
Instead of adding the Nodereferrer field to the view, try adding the Nodereferrer relationship then adding the Node title (using that relationship) as a field. You should be able to sort from newest to oldest, and then set the view to be Distinct so that only the first row for each person shows up.

Resources