ruby - disable an image based on what page are you on -


i have strange issue implement. i've been thinking time cannot come solution.

so lets visited www.rene.com/promotions/hitman .on rhs of page have side bad showing other promotion images. want hide image hitman sidebar. cut story short, when on promotion page, picture on right sidebar related promo visited wont show. right hand sidebar uses loop , loads of images. how can relate right hand sidebar promotion visited? thing in common name of promo , folder promo images:

promo link: www.rene.com/promotions/hitman

sidebar image: /img/promotions/hitman/250x90.jpg

solution 1

find matching data between current environment , data in loop iterating. can find useful information in request. instance if image wish skip has src or href, can match against request environment url (usually request.env['path_info']) or similar.

if href of image/link same path info in request, should skip current iteration (next) since rendering link page on.

solution 2

working ramaze, how solve problem. first need state few assumptions/claims.

you possibly have layout template, or index template render 2 different templates (your page, , "right hand sidebar") need match between. if layout or index template renders partial need match, solution lies in sending match parameter partial.

your controller (due url it's called promotions.rb) should (or may) hold action method called hitman. method represents action of visiting page promotions/hitman. declare variable here can used throughout instance (instance variable, read more here).

you have instance variable may use in layout/index template , send parameter partial.

in partial, need receive , match object iterating on (in example, image url) - if match hide image (or skip iteration using next in loop).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -