You probably want to add a model find and assign the results to something like @posts in the controller, then replace the content section with something using your @posts variable and repeat over it. Start simple, say as a collection and work up from there to what you're after. Otherwise, if you don't need a separate posts/index action, you could just change your default route to go to the posts controller with index action and make your customization there.
On Dec 18, 7:06 am, Ian Wood <[email protected]> wrote: > Hi Owen, many thanks for your reply. I am extremely glad to hear that > I am not the only programmer who has initially struggled after picking > up Hobo. I am also very grateful to everyone that has attempted to > help me thus far, I really appreciate people taking time out of their > day to try and help some hopeless newcomer! I understand that the top > guys in Hobo-land should be left free to make Hobo even better, that > is absolutely where their talents should be utilised. I have found > that in many ways my frustration with Hobo is born out of a > realisation that it is an amazing tool, and exactly what I am looking > for! I just don't know how to use it properly. Yet! As I said before I > am extremely keen to cut my teeth in Hobo, and would love to be able > to contribute to it's development in any way that I can be helpful. PS > Brett, many thanks for your post. You are right, that is definitely > more help than I was after! Your code has helped me understand a few > DRYML related things better, I think it is finally beginning to click! > Unfortunately I am still floundering a little with my initial problem: > How to display information and links from only one model in the index > page (index.dryml) The DRYML that was generated for me automatically > is under 20 lines in total and displays content and creates links to > every available model using an array, what I am after (seems to me) to > be even simpler than this. I'm just not sure about how to set the > context of my query in DRYML. I have managed to work out how to set > the context for the links on the page, so I now have only the wanted > link to create a new post. All I have left to figure out is how to > restrict the repeat on the page to only the post model. > > index.dryml currently looks like this: > > <page title ="Home"> > <body: class = "index-page" for ="Home"/> > > <content:> > <span class="view model:post"> > <a href="/posts/new">New Blog Post</a> > </span> > > <section class="content-body" repeat="&front_models"> > <collection:all/> > </section> > </content:> > > </page> > > The problem is repeat="&front_models" this seems to be an array of all > models? I can't find any information on how to change this focus. > I also thought I might be able to restrict what was being displayed > using the <collection> tag, but thus far I have only found two > parameters that it will accept: "recent" and "all" > It is so frustrating to be utterly stumped by something so simple. > Please someone put me out of my misery! > > Ian. > > On Dec 17, 10:58 am, James Garlick <[email protected]> wrote: > > > > If I were using standard Rails I might redirect the "Home" > > controller to the > > > "Posts" view using: redirect_to(:action => 'Posts') but this > > > doesn't work with Hobo because all of the views are DRYML not ERB. > > > Why do you say that? That should work fine in Hobo, but since you are > > in a different > > controller you'd need to do something like redirect_to object_url(Post) > > > On 16 Dec 2008, at 18:10, Ian Wood wrote: > > > > Yes I have already found the definitions that are automatically > > > defined at apps/views/taglibs/auto/rapid/, my problem is that I cannot > > > find any up to date information on how to call these definitions, and > > > the views are not created for me so I can't check pre-existing code. > > > So for example, I have > > > > <def tag="index-page" for="Post"> > > > <page merge title="Posts"> > > > <body: class="index-page post" param/> > > > > <content: param> > > > <header param="content-header"> > > > <h2 param="heading">Posts</h2> > > > > <p param="count" if>There <count prefix="are"/></p> > > > </header> > > > > <section param="content-body"> > > > > <a action="new" to="&model" param="new-link"/> > > > > <page-nav param="top-page-nav"/> > > > > <collection param/> > > > > <page-nav param="bottom-page-nav"/> > > > </section> > > > </content:> > > > </page> > > > </def> > > > > in apps/views/taglibs/auto/rapid/pages.dryml > > > but I don't know how to use this correctly within another page. I can > > > see that it is creating a link to the "Posts" model but with no > > > explanations available it's quite hard to tell how this is happening. > > > Even the DRYML information on passing parameters seems to be out of > > > date so I have no clue how to call anything! All I need is one working > > > and up to date example of how to define a call to a single model > > > instead of an array of models. As standard in index.dryml it uses: > > > repeat="&front_models" which is obviously all the models. But in the > > > defs above it is calling "&model" but how is it's focus being defined? > > > Is it by the class, or is it simply that this page will already be > > > linked to the relevant model by default? If so how do I create these > > > associations for the "home" page? Sorry if what I am asking seems very > > > simple, but I have been trying to work out how this works for days > > > now, and I simply can't find any information explaining it. If I were > > > using standard Rails I might redirect the "Home" controller to the > > > "Posts" view using: redirect_to(:action => 'Posts') but this > > > doesn't work with Hobo because all of the views are DRYML not ERB. > > > > On Dec 16, 5:22 pm, James Garlick <[email protected]> wrote: > > >> They are created, just all in one file at app/views/taglibs/auto/ > > >> rapid/ > > >> pages.dryml. You can't edit that file directly > > >> as it is generated dynamically but maybe you can use the definitions > > >> in there to help you write the front page. > > > >> On 16 Dec 2008, at 16:20, Ian Wood wrote: > > > >>> I think I have explained myself a bit misleadingly. Thanks to your > > >>> post I have got to grips with how to control what tabs display in my > > >>> app. The final piece of the puzzle for me is to work out how I go > > >>> about replicating the appearance of the "post" page on the "home" > > >>> page. As it stands index.dryml creates an array and populates it > > >>> with > > >>> the names of all of the models I have created. This creates links > > >>> for > > >>> each of the models on the "home" page. The final part of my > > >>> problem is > > >>> redefining this and replacing it with a display of only the "post" > > >>> model. I'm a little lost with this because show.dryml pages for > > >>> all of > > >>> the models aren't created as standard so I have nothing to go on! > > > >>> On Dec 16, 4:12 pm, James Garlick <[email protected]> wrote: > > >>>> Replace the main navigation on your front page with a custom one > > >>>> just > > >>>> for that page: > > > >>>> app/views/front/index.dryml > > > >>>> <page> > > >>>> <main-nav: replace> > > >>>> <navigation class="main-nav"> > > >>>> <nav-item with="&Post">Posts</nav-item> > > >>>> </navigation> > > >>>> </main-nav:> > > >>>> </page> > > > >>>> On 16 Dec 2008, at 16:00, Ian Wood wrote: > > > >>>>> Hi James. > > > >>>>> Thank you! This is part of what I was looking for! > > >>>>> I've now redefined the <main-nav> tag so the navigation is now > > >>>>> fixed > > >>>>> without breaking the route to posts. > > >>>>> So the final part of my problem is how to get index.dryml to only > > >>>>> display "posts" instead of all of the models I have defined. > > > >>>>> On Dec 16, 2:35 pm, James Garlick <[email protected]> wrote: > > >>>>>> You have removed the posts route, so you won't be able to > > >>>>>> navigate > > >>>>>> to / > > >>>>>> posts anymore. I don't think that is what you wanted. > > > >>>>>> Customising the navigation is easy, all you have to do is > > >>>>>> redefine > > >>>>>> <main-nav>, there's an example of this in the cookbook > > >>>>>> app:http://github.com/tablatom/hobocookbook/tree/master/app/views/taglibs > > >>>>>> ... > > > >>>>>> On 16 Dec 2008, at 13:47, [email protected] wrote: > > > >>>>>>> Hello all. > > > >>>>>>> I have what is probably an impossibly simple problem: > > > >>>>>>> I have created a Hobo app with 4 models & controllers: post, > > >>>>>>> site, > > >>>>>>> sound & image > > > >>>>>>> I want the tabbed navigation to show: home, site, sound, image > > >>>>>>> with > > >>>>>>> the "home" tab containing the "post" information. > > > >>>>>>> I defined: auto_actions :all, :except => :index in the "posts" > > >>>>>>> controller to remove it from the tabs. > > > >>>>>>> Now I need to redefine the app/views/front/index.dryml page so > > >>>>>>> that it > > >>>>>>> only shows "posts" as it currently shows "images" "sounds" and > > >>>>>>> "sites" > > > >>>>>>> I understand that this is because it is repeating "front_models" > > >>>>>>> but > > >>>>>>> how do I call a specific model? I'm finding customising Hobo > > >>>>>>> quite > > >>>>>>> hard because lots of the information I have found on the topic > > >>>>>>> (Especially using DRYML and Rapid Tags) doesn't work! Very > > >>>>>>> confusing > > >>>>>>> for the newcomer. > > > >>>>>>> Thanks. > > > >>>>>>> Ian. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
