{"action":"created","issue":{"url":"https://api.github.com/repos/omeka/omeka-s/issues/343","labels_url":"https://api.github.com/repos/omeka/omeka-s/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/omeka/omeka-s/issues/343/comments","events_url":"https://api.github.com/repos/omeka/omeka-s/issues/343/events","html_url":"https://github.com/omeka/omeka-s/issues/343","id":101982638,"number":343,"title":"Representations: Allow \"public\" vs. \"admin\" URL generation","user":{"login":"zerocrates","id":298975,"avatar_url":"https://avatars.githubusercontent.com/u/298975?v=3","gravatar_id":"","url":"https://api.github.com/users/zerocrates","html_url":"https://github.com/zerocrates","followers_url":"https://api.github.com/users/zerocrates/followers","following_url":"https://api.github.com/users/zerocrates/following{/other_user}","gists_url":"https://api.github.com/users/zerocrates/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocrates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocrates/subscriptions","organizations_url":"https://api.github.com/users/zerocrates/orgs","repos_url":"https://api.github.com/users/zerocrates/repos","events_url":"https://api.github.com/users/zerocrates/events{/privacy}","received_events_url":"https://api.github.com/users/zerocrates/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/omeka/omeka-s/labels/feature","name":"feature","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"jimsafley","id":141955,"avatar_url":"https://avatars.githubusercontent.com/u/141955?v=3","gravatar_id":"","url":"https://api.github.com/users/jimsafley","html_url":"https://github.com/jimsafley","followers_url":"https://api.github.com/users/jimsafley/followers","following_url":"https://api.github.com/users/jimsafley/following{/other_user}","gists_url":"https://api.github.com/users/jimsafley/gists{/gist_id}","starred_url":"https://api.github.com/users/jimsafley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimsafley/subscriptions","organizations_url":"https://api.github.com/users/jimsafley/orgs","repos_url":"https://api.github.com/users/jimsafley/repos","events_url":"https://api.github.com/users/jimsafley/events{/privacy}","received_events_url":"https://api.github.com/users/jimsafley/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/omeka/omeka-s/milestones/10","html_url":"https://github.com/omeka/omeka-s/milestones/August%2028","labels_url":"https://api.github.com/repos/omeka/omeka-s/milestones/10/labels","id":1258706,"number":10,"title":"August 28","description":"","creator":{"login":"zerocrates","id":298975,"avatar_url":"https://avatars.githubusercontent.com/u/298975?v=3","gravatar_id":"","url":"https://api.github.com/users/zerocrates","html_url":"https://github.com/zerocrates","followers_url":"https://api.github.com/users/zerocrates/followers","following_url":"https://api.github.com/users/zerocrates/following{/other_user}","gists_url":"https://api.github.com/users/zerocrates/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocrates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocrates/subscriptions","organizations_url":"https://api.github.com/users/zerocrates/orgs","repos_url":"https://api.github.com/users/zerocrates/repos","events_url":"https://api.github.com/users/zerocrates/events{/privacy}","received_events_url":"https://api.github.com/users/zerocrates/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":7,"state":"open","created_at":"2015-08-17T17:02:04Z","updated_at":"2015-08-21T22:13:53Z","due_on":"2015-08-28T04:00:00Z","closed_at":null},"comments":3,"created_at":"2015-08-19T19:48:29Z","updated_at":"2015-08-22T15:19:12Z","closed_at":null,"body":"The representations' URL generation currently is set up to produce API URLs and admin-side URLs. This won't be suitable for use on the public-side pages, or for linking from the admin to the public, or vice-versa.\r\n\r\nThe easiest route here is probably to just create a third URL method that's just for making public URLs. Alternatives include having some automatic code and/or flag for the existing url method that tells whether public or admin URLs should be generated (and having the default be whatever side is current)."},"comment":{"url":"https://api.github.com/repos/omeka/omeka-s/issues/comments/133714961","html_url":"https://github.com/omeka/omeka-s/issues/343#issuecomment-133714961","issue_url":"https://api.github.com/repos/omeka/omeka-s/issues/343","id":133714961,"user":{"login":"jimsafley","id":141955,"avatar_url":"https://avatars.githubusercontent.com/u/141955?v=3","gravatar_id":"","url":"https://api.github.com/users/jimsafley","html_url":"https://github.com/jimsafley","followers_url":"https://api.github.com/users/jimsafley/followers","following_url":"https://api.github.com/users/jimsafley/following{/other_user}","gists_url":"https://api.github.com/users/jimsafley/gists{/gist_id}","starred_url":"https://api.github.com/users/jimsafley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimsafley/subscriptions","organizations_url":"https://api.github.com/users/jimsafley/orgs","repos_url":"https://api.github.com/users/jimsafley/repos","events_url":"https://api.github.com/users/jimsafley/events{/privacy}","received_events_url":"https://api.github.com/users/jimsafley/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T15:19:11Z","updated_at":"2015-08-22T15:19:11Z","body":"Here's one solution that requires only one change to `AbstractResourceRepresentation::url()`: append `$public = null` flag to the signature. Representations that have a public url will override the method, check against the current route and the flag, and either hand off to `parent::url()` to generate an admin URL or generate a public URL. Something like this in `ItemRepresentation`:\r\n\r\n```php\r\npublic function url($action = null, $canonical = false, $public = null)\r\n{\r\n    $routeMatch = $this->getServiceLocator()->get('Application')\r\n        ->getMvcEvent()->getRouteMatch();\r\n    if ($routeMatch->getParam('__ADMIN__') && !$public) {\r\n        return parent::url($action, $canonical);\r\n    }\r\n\r\n    $url = $this->getViewHelper('Url');\r\n    return $url(\r\n        'site/show',\r\n        array(\r\n            'site-slug' => $action,\r\n            'id' => $this->id(),\r\n        ),\r\n        array('force_canonical' => $canonical)\r\n    );\r\n}\r\n``` \r\n\r\nThis assumes that admin URLs will not be generated while on a public route, which may be a wrong assumption."}}