Suppose I have created a model, name = abc
as satellites I have : H_ABC, S_ABC, SB_ABC
in the H_ABC i have two natural keys key1, key2
and in SB_ABC i have 3 payload columns, 2 of them are coming from S_ABC
but one of them is coming from H_ABC
I have tried to use for instance:
{{
satellite(
source_model='H_ABC',
payload_columns=[
some columns
]
}}
{{
satellite(
source_model='S_ABC',
payload_columns=[
some columns
]
}}
S_ABC is fine, but I can't use the one column that I need in the first one ?
My question: Can i referance from two difference satellite in one satellite ?
For example I have a property matrix with 2 fields. Buy and Rental.
Within Buy and Rental I have a date field as well as various other fields like a heading etc.
I would like to order ALL of the properties by date - the value of the date field in each block.
Since we don't have any code to go by I will give it a shot in the dark anyway.
In your template you could use some Craft queries. For a category query it would look like this (entries could be the same as well):
{% set categories = craft.categories().orderBy('dateCreated asc').all() %}
All this does is fetch the categories, then orders them by the date created in ascending order. You can change dateCreated to postDate and asc to desc if you need to.
If you need a specific category group you would use {% set categories = craft.categories().group(myCategoryGroup).orderBy('dateCreated asc').all() %}
Instead of running the above you could also run:
{% set categories = craft.categories().orderBy('dateCreated asc').all() %}
{% set cateByDate = categories|group('postDate|date("Y")') %}
Again, same concept just we are querying by a specific group of categories.
Next you will have to setup a loop to iterate through the categories.
{% for category in categories %}
<p>{{ category.dateCreated|date("M/d/Y")}}</p>
{% endfor %}
This is a simple overview of how the problem can be approached, but we don't have code to be able to help more. There are many different possibilities.
Joining Date : 975628800
{{ timestamp|format_date('field_joining_date') }}
How to convert this timestamp format to date format?
I am trying to list all items in a section of Kentico as a drop-down list but want only one field value to be returned for each document.
What I have tried
Lists Nothing:
Documents.WithAllData["/Foo/Bar/Bar"].AllChildren.WithAllData.All.GetValue("FooBar")
Lists all document information:
Documents.WithAllData["/Foo/Bar/Bar"].AllChildren
You'd use a macro similar to this:
<select id="ddlItems">
{% Documents["/Foo/Bar/Bar"].Children.WithAllData.ApplyTransformation("cms.event.transformationname") %}
</select>
To list out all your items. The transformation will then have your column information:
<option>{% FooBar %}</option>
**** UPDATE ****
Based on your comment, you can simply use a sql query (which a macro will run anyway). If you know what page type you want to query you can go directly to that page type's table:
SELECT Col1, Col2, FROM Content_YourTable
If you need the data from your page type based on a particular path in the tree, then you can use something like this:
SELECT Col1, Col2
FROM View_CMS_Tree_Joined
INNER JOIN CONTENT_MenuItem on DocumentForeignKeyValue = MenuItemID
WHERE NodeAliasPath like '/Foo/Bar/Bar/%'
AND Classname = 'cms.menuitem'
Nb. I am using PostgreSQL.
Nb1. For simplicity purposes I am only showing the two relevant columns for this post, original table has more rows & columns.
I have a table called 'contents' like this:
<!DOCTYPE html>
<html>
<body>
<table border="1" style="width:100%">
<tr>
<td>id</td>
<td>data</td>
</tr>
<tr>
<td>4009</td>
<td>"duration"=>"101", "preview_version"=>"", "twitter_profile"=>"", "creator_category"=>"association", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "content_expertise_type"=>"image", "content_expertise_categories"=>"1,2,3"</td>
</tr>
<tr>
<td>4865</td>
<td>"duration"=>"108", "preview_version"=>"", "twitter_profile"=>"", "creator_category"=>"association", "facebook_profile"=>"", "linkedin_profile"=>"", "personal_website"=>"", "content_expertise_type"=>"image", "content_expertise_categories"=>"4,6"</td>
</tr>
</table>
</body>
</html>
from this table I need to extract the duration value by using this query:
select id,data->'duration' as data from contents
which gives me the below result (again, the original table will return many more entries and some values in "data" column will coincide reason why I need to group them in ranges):
+------+------+
| id | data |
+------+------+
| 4009 | 101 |
| 4865 | 108 |
+------+------+
Now that I have the 'data' values I want to tag them in different ranges
SELECT d.id,
case when d.data >= 0 and d.data< 10 then '0-9'
when d.data >= 10 and d.data< 20 then '10-19'
else '20-500' end as range
FROM (SELECT id,data->'duration' as data FROM contents) as d
But here the query returns this error:
ERROR: operator does not exist: text >= integer
LINE 3: case when d.data >= 0 and d.data< 10 then '0-9'
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
After this I was hoping to group the ranges like this:
SELECT t.range as score_range, count(*) as number_of_ocurrences
FROM
(***ABOVE QUERY THAT CURRENTLY RETURNS AN ERROR TO BE PLACED IN HERE***) as t
GROUP BY t.range
ORDER BY score_range
Any help to achieve this grouping task will be very much appreciated!
Looking forward to getting an answer! :-)
Thanks!
Json values in Postgres are always strings, it is necessary to cast. For fetching integer values from json fields there is a special operator ->>
Try to fetch duration as Integer value like
select id, data->>'duration' as data from contents
More info http://www.postgresql.org/docs/9.3/static/functions-json.html
It should work if you cast the value:
SELECT d.id,
(case when d.data >= 0 and d.data< 10 then '0-9'
when d.data >= 10 and d.data< 20 then '10-19'
else '20-500'
end) as range
FROM (SELECT id, (data->'duration')::int as data FROM contents
) d