{"action":"created","issue":{"url":"https://api.github.com/repos/e107inc/e107/issues/1691","repository_url":"https://api.github.com/repos/e107inc/e107","labels_url":"https://api.github.com/repos/e107inc/e107/issues/1691/labels{/name}","comments_url":"https://api.github.com/repos/e107inc/e107/issues/1691/comments","events_url":"https://api.github.com/repos/e107inc/e107/issues/1691/events","html_url":"https://github.com/e107inc/e107/issues/1691","id":159144997,"number":1691,"title":"[question] How to use container class (col-md-) conditionally in template files?","user":{"login":"lonalore","id":6043821,"avatar_url":"https://avatars.githubusercontent.com/u/6043821?v=3","gravatar_id":"","url":"https://api.github.com/users/lonalore","html_url":"https://github.com/lonalore","followers_url":"https://api.github.com/users/lonalore/followers","following_url":"https://api.github.com/users/lonalore/following{/other_user}","gists_url":"https://api.github.com/users/lonalore/gists{/gist_id}","starred_url":"https://api.github.com/users/lonalore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lonalore/subscriptions","organizations_url":"https://api.github.com/users/lonalore/orgs","repos_url":"https://api.github.com/users/lonalore/repos","events_url":"https://api.github.com/users/lonalore/events{/privacy}","received_events_url":"https://api.github.com/users/lonalore/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-08T11:52:04Z","updated_at":"2016-06-08T12:30:14Z","closed_at":null,"body":"Just a simple example:\r\n\r\nSuppose that I have a template file, which contains something like this:\r\n```html\r\n<div class=\"row\">\r\n    <div class=\"col-md-4\">\r\n        {NEWSIMAGE}\r\n    </div>\r\n    <div class=\"col-md-8\">\r\n        {NEWSBODY}\r\n    </div>\r\n</div>\r\n```\r\n\r\nBut what if I want to use `col-md-12` for news-body if no image? How can I achive this?\r\n\r\nSo, if no image for news item, the layout would be this:\r\n```html\r\n<div class=\"row\">\r\n    <div class=\"col-md-12\">\r\n        {NEWSBODY}\r\n    </div>\r\n</div>\r\n```\r\n\r\nOnly solution I know is overriding `news_schortcodes.php` (I copy `e107_core/shortcodes/batch/news_shortcodes.php` file into `e107_core/override/shortcodes/batch` folder) and modifying it according to my custom needs. For example I create new shortcode methods (`sc_newsimage_class()` and `sc_newsbody_class()`) to get CSS class depending on whether or not the image exists.\r\n\r\nFinally, template would be this:\r\n```html\r\n<div class=\"row\">\r\n    <div class=\"{NEWSIMAGE_CLASS}\">\r\n        {NEWSIMAGE}\r\n    </div>\r\n    <div class=\"{NEWSBODY_CLASS}\">\r\n        {NEWSBODY}\r\n    </div>\r\n</div>\r\n```\r\nIf no image, {NEWSIMAGE_CLASS} would return with 'hidden', and {NEWSBODY_CLASS} with 'col-md-12'.\r\n\r\nHowever, this is not a good solution, because the whole shortcode class (file) will be overrided, and it's hard to keep track of changes with each (core) update.\r\n\r\nThe best solution would be that:\r\n- we could inject new methods into a shortcode class\r\n- and we could override a method in a shortcode class (without overriding the whole class)\r\n\r\nWhat would be the best solution to achive this?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/e107inc/e107/issues/comments/224574284","html_url":"https://github.com/e107inc/e107/issues/1691#issuecomment-224574284","issue_url":"https://api.github.com/repos/e107inc/e107/issues/1691","id":224574284,"user":{"login":"Jimmi08","id":5429548,"avatar_url":"https://avatars.githubusercontent.com/u/5429548?v=3","gravatar_id":"","url":"https://api.github.com/users/Jimmi08","html_url":"https://github.com/Jimmi08","followers_url":"https://api.github.com/users/Jimmi08/followers","following_url":"https://api.github.com/users/Jimmi08/following{/other_user}","gists_url":"https://api.github.com/users/Jimmi08/gists{/gist_id}","starred_url":"https://api.github.com/users/Jimmi08/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jimmi08/subscriptions","organizations_url":"https://api.github.com/users/Jimmi08/orgs","repos_url":"https://api.github.com/users/Jimmi08/repos","events_url":"https://api.github.com/users/Jimmi08/events{/privacy}","received_events_url":"https://api.github.com/users/Jimmi08/received_events","type":"User","site_admin":false},"created_at":"2016-06-08T12:30:13Z","updated_at":"2016-06-08T12:30:13Z","body":"I am using this:\r\nhttps://github.com/Jimmi08/e107_snippets/issues/8\r\n\r\n"}}
{"actor":{"display_login":"Jimmi08"}}