{"id":3274,"date":"2011-03-14T18:57:04","date_gmt":"2011-03-14T13:27:04","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=3274"},"modified":"2011-03-14T18:57:04","modified_gmt":"2011-03-14T13:27:04","slug":"inlink-tag-to-provide-links-to-important-words-in-the-contents","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/inlink-tag-to-provide-links-to-important-words-in-the-contents\/","title":{"rendered":"InLink tag : To provide links to important words in the contents."},"content":{"rendered":"<p>Hi , this is a very simple but yet\u00a0useful tag to provide links to important words in the content given in between the starting and end inLink tag.<\/p>\n<p>Taking an <strong>Example<\/strong> of contents :-<\/p>\n<p>&#8220;No One Killed Jessica is a 2011 Hindi film starring Vidya Balan and Rani Mukherjee , produced by UTV Spotboy and directed by Raj Kumar Gupta, who had earlier directed the acclaimed film Aamir (2008).\u00a0Vidya Balan plays the character of Jessica\u2019s elder sister, Sabrina Lal, Rani is set to play a reporter.[7]\u00a0. The director clarified that the title and the script are actually inspired by a headline carried out by The Times of India (epaper link) in 2006, when the accused in the infamous murder case were acquitted by the lower courts.The film, No One Killed Jessica is based on the true story of Jessica Lal, a Delhi-based model, who was shot in 1999 at a New Delhi restaurant by Manish Bhardwaj, alias Manu, the son of an influential Haryana politician.In February 2006, the court acquitted. \u00a0It received positive reviews from critics.[12]No One Killed Jessica opened quite well and got positive feedback from audience.No One Killed Jessica received a number of positive reviews. Nikhat Kazmi of the Times of India gave the movie four stars out of five stating. &#8221;<\/p>\n<p><strong>Output<\/strong> after passing the contents between inLink tag :<strong>&#8211;<\/strong><\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/Screenshot-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3315\" title=\"Screenshot-1\" src=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/Screenshot-1.png\" alt=\"\" width=\"495\" height=\"166\" \/><\/a><\/p>\n<p>This tag takes celebrity list and movie list as input and then just replaces each \u00a0celebrity name or \u00a0movie name with its link which takes to the corresponding celebrity page or movie page.<\/p>\n<p>Now the <strong>code for the inLink tag <\/strong>is as follows :-<\/p>\n<p>[java]<br \/>\ndef inLink = {attrs, body -&gt;<br \/>\nList&lt;Celebrity&gt; celebrities = attrs[&#8216;celebrities&#8217;]<br \/>\nList&lt;Movie&gt; movies = attrs[&#8216;movies&#8217;]<br \/>\nString bodyText = body()<br \/>\nString currentCelebrity<br \/>\nString currentMovie<br \/>\ncelebrities.each {currentSelect -&gt;<br \/>\ncurrentCelebrity = currentSelect.name<br \/>\nbodyText = bodyText.replaceAll(currentCelebrity, (hys.celebrityPageLink(id: currentSelect.id,title:currentCelebrity ) {currentCelebrity}).toString())<br \/>\n}<br \/>\nmovies.each {currentSelect -&gt;<br \/>\ncurrentMovie = currentSelect.name<br \/>\nbodyText = bodyText.replaceAll(currentMovie, (hys.moviePageLink(id: currentSelect.id,title:currentMovie) {currentMovie}).toString())<br \/>\n}<br \/>\nout &lt;&lt; bodyText<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>Here ,two more tags :- celebrityPageLink tag and moviePageLink tag are used which are defined under the namespace &#8220;hys&#8221; .These two tags are very similar ,one links its given content i.e. celebrity name to its corresponding celebrity page and the one links its given content i.e. movie name to its corresponding movie page. Lets see the code for one of these tags for sake of avoiding confusion regarding these.<\/p>\n<p>Taking <strong>celebrityPageLink tag<\/strong> which takes celebrity id,title and class as input. Its <strong>code<\/strong> is as follows :-<\/p>\n<p>[java]<\/p>\n<p>def celebrityPageLink = {attrs, body -&gt;<\/p>\n<p>def celebrity = Celebrity.read(attrs.id)<\/p>\n<p>out &lt;&lt; g.link(controller: &#8216;celebrity&#8217;, action: &#8216;show&#8217;, params: [name: celebrityName]) {body()}<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>Now lets see <strong>how to use this tag on gsp page :-<\/strong><\/p>\n<p>[html] &lt;hys:inLink movies=&quot;${allMovies}&quot; celebrities=&quot;${movie.getCelebrities()}&quot;&gt;${movie.description}&lt;\/hys:inLink&gt; [\/html]<\/p>\n<p>ok&#8230;&#8230;now lets see how much its useful for grails users.<\/p>\n<p>Regards,<\/p>\n<p><strong>Shweta Gupta<\/strong><\/p>\n<p><strong>Intelligrape<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi , this is a very simple but yet\u00a0useful tag to provide links to important words in the content given in between the starting and end inLink tag. Taking an Example of contents :- &#8220;No One Killed Jessica is a 2011 Hindi film starring Vidya Balan and Rani Mukherjee , produced by UTV Spotboy and [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3274"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=3274"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3274\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=3274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=3274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=3274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}