Re: [Radiant] Search for a relative item
Andrew Neil wrote: I've just been working on an extension for accessing neighbouring sibling pages[1], and I found that the following does not work: tag.locals.page.siblings.find(...) when you call find() on the siblings, you are actually calling the method from Ruby's enumerable module, rather than from ActiveRecord::Base. So in actual fact, it is necessary to call instead: tag.locals.page.parent.children.find(...) which still uses ActiveRecord::Base.find(). If you need to exclude the current page from the result set, you could do so by passing a condition: :conditions => ["id != ?", tag.locals.page.id] or something similar. There was a discussion on why find() behaves differently in each situation a few days ago, but it was on the [Radiant-dev] list (google groups). Drew [1]:http://github.com/nelstrom/radiant-sibling-tags-extension/tree/master Thanks for the detailed information, Drew. It'll take a while for me to get through it and to see how it applies to my case. I think I might need it, but there are ways in my case that I could avoid the hassle. Let's see which way it goes. Cheers, Mohit. 9/1/2008 | 12:36 AM. ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Re: [Radiant] Search for a relative item
On 30 Aug 2008, at 18:25, Sean Cribbs wrote: Maybe a simple tag is in order here: Where the sibling tag is defined as: tag 'sibling' do |tag| tag.locals.page = tag.locals.page.siblings.find {|s| s.slug == tag.attr['slug'] }; tag.expand if tag.locals.page end If you want (or can settle for) all of the sibling links, use . I've just been working on an extension for accessing neighbouring sibling pages[1], and I found that the following does not work: tag.locals.page.siblings.find(...) when you call find() on the siblings, you are actually calling the method from Ruby's enumerable module, rather than from ActiveRecord::Base. So in actual fact, it is necessary to call instead: tag.locals.page.parent.children.find(...) which still uses ActiveRecord::Base.find(). If you need to exclude the current page from the result set, you could do so by passing a condition: :conditions => ["id != ?", tag.locals.page.id] or something similar. There was a discussion on why find() behaves differently in each situation a few days ago, but it was on the [Radiant-dev] list (google groups). Drew [1]:http://github.com/nelstrom/radiant-sibling-tags-extension/tree/master ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Re: [Radiant] Search for a relative item
Sean Cribbs wrote: Mohit Sindhwani wrote: Hi, this is one of my first posts in a while where I'm not asking someone to write for the Summer Reboot. I need help! [1] Can I search for a relative page? Is there any way to do a search for a relative item in this sense? Or must each page definitely be linked within a specific link to that version? Or should I just do a relative 'link' (../hash) rather than doing a search. Maybe a simple tag is in order here: Where the sibling tag is defined as: tag 'sibling' do |tag| tag.locals.page = tag.locals.page.siblings.find {|s| s.slug == tag.attr['slug'] }; tag.expand if tag.locals.page end If you want (or can settle for) all of the sibling links, use . [2] Binary Data The other problem is more Ruby-related, I think. I'm writing a script to extract data from the Word document and then automatically create the pages. One of the pages has a 'micro' character in it (μ) and this looks OK in the text file but it doesn't show up in the pages correctly. Any idea what I should do? I would escape the characters into HTML entities before you write it to the page. Not sure what the 'micro' character corresponds to (or what character set it is in originally), but it should be easy to look up if you have to. Try out the CGI::escape* methods. Thanks for the super-quick answers, Sean! The sibling tag looks perfect (though I was starting to lean towards a hard-coded HTML link itself) and I'll look at HTML entities now. Cheers Mohit. ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Re: [Radiant] Search for a relative item
Mohit Sindhwani wrote: Hi, this is one of my first posts in a while where I'm not asking someone to write for the Summer Reboot. I need help! [1] Can I search for a relative page? I am trying to convert an API document to HTML to be hosted within Radiant. The system will hold multiple versions of the original document, e.g. v1.00.00 then v1.01.00 and so on. So, it will hold numerous same-named eventual pages: /doc/v1.00/file/ /doc/v1.01/file/ /doc/v1.02/file/ and so on. Between the pages of each version, I'd like to create links between 'file' and other pages (e.g. file and say, 'hash') but it should stay within the same version. So, /doc/v1.00/file --> /doc/v1.00/hash and /doc/v1.01/file/ and /doc/v1.01/systemcall/ Is there any way to do a search for a relative item in this sense? Or must each page definitely be linked within a specific link to that version? Or should I just do a relative 'link' (../hash) rather than doing a search. Maybe a simple tag is in order here: Where the sibling tag is defined as: tag 'sibling' do |tag| tag.locals.page = tag.locals.page.siblings.find {|s| s.slug == tag.attr['slug'] }; tag.expand if tag.locals.page end If you want (or can settle for) all of the sibling links, use . [2] Binary Data The other problem is more Ruby-related, I think. I'm writing a script to extract data from the Word document and then automatically create the pages. One of the pages has a 'micro' character in it (μ) and this looks OK in the text file but it doesn't show up in the pages correctly. Any idea what I should do? I would escape the characters into HTML entities before you write it to the page. Not sure what the 'micro' character corresponds to (or what character set it is in originally), but it should be easy to look up if you have to. Try out the CGI::escape* methods. Cheers, Sean ___ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant