how to list children pages in drupal 6 - drupal-6

Using the node api i would like to create an array of children nodes.
for example in the menu say i had
Sports
Football
Cricket
How can i list these in php

Assuming you want your hierarchy to be managed from a Drupal menu, you can do this:
start with:
$data = menu_tree_page_data('menu-name')
The children live in the data in something like this:
$data['LONG-KEY MENU-NAME MENU-ID']['below'])
I usually do a little print_r($data,true) to identify the actual key of $data where the children live.. the key naming structure is a little odd to me.. it's not terribly intuitive.
There's a lot going on in the data array there.. more than you need to get an array of children nodes..
I've got an in-depth blog post on this (but geared toward menu implementation rather than a node api list of nodes..) here:
http://www.trevorsimonton.com/blog/sub-menu-children-menu-items-block-menu-children-blocks-sibling

Related

How to display databases values with fltk widgets

I'm developing an application - written in rust, that registers items in a database, but I'm having trouble showing the data in a way that is visually good, I tried to use the Browser widget but it's not visually appealing. I have a struct Items that store name, quantity and price, and a vector of Items that stores the field values, how can I show the items stored in the database, and what is the best widget to do that?
Natural choice would be to use the Fl_Table and Fl_Table_Row classes in your project.
Greg Ercolano has an example how to use them at https://www.seriss.com/people/erco/fltk/Fl_Table/ . In fact, he is the original author of these classes, later on they got into the FLTK itself...
Do not be confused with the screenshot when you see those buttons inside the table. - He just wanted to demonstrate that you can put any Widget in Fl_Table cells.

CouchDB: In a checklist app, new file for every list item?

I'm working on a checklist web app
Now, every user can have lots of check lists, each with many items on them.
Would it be a good idea to keep the items in a JS object in the individual checklist? This would have been my first approach, since there wouldn't be a lot of sorting or anything happening on those items.
Now I'm thinking about putting every item in an individual file (because I might do stuff like deadlines and assignments for individual items)
This seems like a lot of files to me. Maybe I underestimate CouchDB. Would this be a good approach to the problem?
Store every list item as new document.
Every list item document should have properties like listname, deadline and/or assignment.
You don't need (but you can have) extra docs to express hierarchy or nested relations. That what CouchDB views for - e.g. you will build a view getListItemsByListname with the listname as key to get all items of one list.

Expression Engine - passing multiple categories as URL segments

I'm trying to create a product filter with deep-linking capability. Essentially, I want the user to be able to filter my product list on multiple categories and have the URL reflect the filtering they've done.
So it would start as:
www.site.com/products/
My first level of category filtering already works. So I can use EE's regular handling of URL segments to get to my first level of filtering. For instance:
www.site.com/products/leatherthongs
Returns a filtered subset showing only a spectacular collection of leather thongs. But now I want the user to be able to filter on another category - color for instance. This is where stuff stops working.
EE's way of handling multiple categories inside templates (with ampersands or pipes) doesn't work in the URL:
www.site.com/products/leatherthongs&red
Nor does any variation that I've tried.
My next move is to create a simple raw PHP method that can capture regular querystring parameters and then inject them into the {entries} tag before rendering. Not very difficult, but quite ugly. I would love to know if there is a way to handle multiple categories in the URL natively.
Thanks for your time.
Have you considered using Low's Seg2Cat add-on? I'm not sure how complex you want to make this but it seems that you could specify something in your channel:entries loop like categories='{segment_2){if segment_3}|{segment_3_category_id}{/if}'
This exact syntax is untested but I have had success in the past with a similar solution.

NSFetchRequest in Core Data

I am having a very hard time understanding what needs to be included in the Children Views in order to perform a fetch request and display the results in a table view when using Core Data. All the examples I have found are either only one layer deep (Random Dates), using the Root View Controller which always works, or using several view controllers with pictures and other attributes (Recipes) that make it confusing for me to follow.
An example of what I am looking for would be an Entity with three attributes. The entity is album and the three attributes are albumTitle, albumArtist and yearRecorded.
Now in my Navigation app my Root View Controller has three rows to choose from not using the Entity or Core Data at all. The three choices are "Title", "Artist" and "Year". When you click on one of the three rows it will push a new view controller and list all of the appropriate attributes in a new table view.
I believe it should be very simple and not require too much code but I can't get a handle on it. Any explanations or sample code is greatly appreciated.
You could just make a fetch request with no predicates to get all the objects from your Core Data store, so, you'll have an array of songs.
Than you just call, for example, [fetchedSongs valueForKeyPath:#"artist"]; to get an arry of artist and add it as a source to your tableview.

How to create and fetch relational records in core data

Total newbie question now... Suffice to say, I have searched for a completely noddy explanation but have not found anything 'dumb' enough. The problem is...
I have created a core data stack in which I have a entity called 'Client' and an entity called 'Car'. It is a one-to-many relationship.
So far i have successfully created and fetched the client list using code from apple's tutorial. Once I select a client, I then push a new tableViewController which should list the Cars for that chosen client.
First question...
I am used to sql style database programming where if I wanted to add a car to a client, I would simply add a 'ClientID' tag to the 'Car' record thereby providing the relationship to a specific client. How do I do the equivalent in core data? My understanding from my reading is adding attributes to point to other entities isnt necessary - core data maintains this relationship for you without needing additional attributes in the entities.
Second question...
As and when I have created a 'car' entity and successfully linked it to a 'Client'. How to I create a fetch which will retrieve just THAT client's cars. I could alter the code from apple to fetch ALL cars but I don't know how to fetch cars associated with a given client. From my reading, I think I need to use predicates, but apples predicate documentation stands alone and does not give clear guidance on how to use it with core data
I realise how noddy this is, but I cant find an idiots guide anywhere...
Any help/code exmaples much appreciated.
OK, I have answered my own question. For those who have found my question and would like to know the answer, it is extremely simple...
Firstly, to create a 'Car' and associate it with a 'Client'. Firstly create a 'Car' as you normally would and simply add this line of code...
newCar.client = client;
This sets the 'client' relationship on the 'Car' record to the client in question.
Secondly, I had thought that if you had a client and needed to find their cars, you would need a new fetch. But not so! Simply use the following lines of code...
NSSet *cars = client.cars;
[self setCarsArray:[cars allObjects]];
The first line uses "client.cars" o follow the object graph to determine the cars this client has and populates them in an NSSet. The second line then populates a NSArray which is declared in the current viewcontroller which can be used to for display purposes.
Sorted!!

Resources