Select This! Entity Selectors in Reason CMS

324 views

Published on

Published in: Technology, Lifestyle
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
324
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Select This! Entity Selectors in Reason CMS

  1. 1. Andrew Bacon ‟13Carleton College
  2. 2. me:
  3. 3. me:
  4. 4. me:
  5. 5. at WSG:
  6. 6. ➡ entities➡ relationships
  7. 7. entities:stuff.
  8. 8. entities:stuff like...➡ sites ➡ news posts➡ pages ➡ images, ...➡ a cat
  9. 9. entities:aggregations ofproperties...➡ id ➡ name➡ type ➡ created_on, ...
  10. 10. entities:some properties onlymake sense forcertain types
  11. 11. entities:some properties only make sense for certaintypes, e. g.:lol_cat boromirbreed
  12. 12. entities:aggregations ofproperties acrossdatabase tables.➡ entity➡ meta➡ chunk➡ newstype, image, ...
  13. 13. Some examples.meta➡ description➡ keywordschunk➡ content➡ authorimage➡ dimension➡ image_typenewstype➡ subtitle➡ on_front_page
  14. 14. Some examples.meta➡ description➡ keywordschunk➡ content➡ authorimage➡ dimension➡ image_typenewstype➡ subtitle➡ on_front_pagenews post
  15. 15. Some examples.meta➡ description➡ keywordschunk➡ content➡ authorimage➡ dimension➡ image_typenewstype➡ subtitle➡ on_front_pageimage
  16. 16. not entities:relationships
  17. 17. relationshipsThings are related to otherthings.➡ entity_a and entity_b
  18. 18. relationshipssilly examples:nation_to_cat_monarch
  19. 19. relationshipssilly examples:lolrus_to_bukkit
  20. 20. relationshipsreal examples:minisite_page_to_avav_to_av_fileminisite_page_to_imagenews_to_image
  21. 21. relationshipsThings are related to otherthings.➡ directional➡ entity_a and entity_b
  22. 22. detour:relationships have direction.➡ unidirectionalminisite_page_to_image
  23. 23. detour:relationships have direction.nation_to_cat_monarch
  24. 24. (disembodied)
  25. 25. detour:relationships have direction.➡ unidirectional➡ bidirectionalsite_to_user
  26. 26. detour:real examples of directionality➡ news_to_image
  27. 27. detour:relationships have direction.focusrelatednews_post_to_...
  28. 28. detour:relationships have direction.image_to_... or ..._to_imagefocusrelated
  29. 29. relationshipsThings are related to otherthings.➡ directional➡ number-sensitive➡ entity_a and entity_b
  30. 30. relationshipssilly examples:nation_to_cat_monarch
  31. 31. relationshipssilly examples:mom_to_kittens
  32. 32. relationshipsreal examples:➡ news_to_image
  33. 33. relationshipsThings are related to otherthings.➡ directional➡ number-sensitive➡ entity_a and entity_b➡ pretty darn arbitrary
  34. 34. entities:stuff like...➡ sites ➡ news posts➡ pages ➡ images, ...➡ types?➡ DB tables?!➡ „type‟!?!?
  35. 35. putting it togethertype_to_table relationships forentity 3, “Site.”rel_id entity_a entity_b rel_type7 Site (3) site (8) 111628 Site (3) meta (82) 194766 Site (3)ldap_cache(37716)1
  36. 36. entities in PHP➡ objects of class Entity➡ linked to corresponding entityin DB (if exists)
  37. 37. entities in PHPmethods to know aboutget_value($name, $value);set_value($name);id();
  38. 38. getting entitiesentity constructorentity selectors
  39. 39. the constructor$e = new Entity($id);
  40. 40. the selector$es =new Entity_Selector($site);
  41. 41. selectorwhy I was afraid➡ no formal introduction
  42. 42. selectorcommon tasksWhat properties of entities can we selectbased on?➡ Type➡ Relationship to a specific entity➡ Has a property with a specific value➡ ...?
  43. 43. selectoradd_type($id);Will select only entities of the given type.$es->add_type(id_of(„image‟));
  44. 44. selectoradd_relation($where);Selects only entities where a specificproperty meets some condition.$es->add_relation(„status.status != “pending”‟);
  45. 45. selectoradd_left_relationship($id[, $rel_id]);selected entities must exist on the left sideof a relationship with $entity_id on the rightside. Optional $relationship_id.“get the parent of thegiven entity.”
  46. 46. selectoradd_right_relationship($id[, $rel_id])selected entities must exist on the right sideof a relationship with $entity_id on the leftside. Optional $relationship_id.“get the child of the givenentity.”
  47. 47. selectorset_env(„site‟, $site_id);always set this.not the same thing as the site id you set inthe $es constructor.
  48. 48. selectorrun_one([$type, $status, $error]);Run the darn thing!Returns an array of entities.
  49. 49. selectoran example:Select all media works from a site➡$es = new Entity_Selector($site);➡$es->add_type(id_of(„av‟));➡$result = $es->run_one()
  50. 50. selectoranother example:Select all images related to a news item (forthis site!)➡$es = new Entity_Selector($site);➡$es->add_type(id_of(„image‟));➡$es->add_right_relationship($news_id,relationship[_id_of(„news_to_image‟));➡$result = $es->run_one()
  51. 51. selectoradd_left_relationship_field($rel_name, $table, $field);If there are entities that are on the left sideof the given relationship, add the givenfield.
  52. 52. selectorhow to look up info about a typeMaster admin -> types
  53. 53. more?!you know enough now.
  54. 54. other thoughtsthat guy sitting next to you isAMAZING with $es.➡ bigger selectors are not better.➡ limit_tables, limit_fields➡ fifth parameter of add_left_rel_field➡ google group: reason-cms
  55. 55. goodies!!!!available atgo.carleton.edu/...slides! cheat sheet!!?!?

×