#51 Re: General » Using Links in Templates » April 6, 2012 12:36pm

Utilizing $www_root and $cms->getLink(), as opposed to hard coding links, also makes launching a site super simple. When moving from your development environment to your live server, simply update 3 lines in the config.php file to the new location of the site and BigTree will take care of updating all internal site links automatically:


// Simply Change:
$config["domain"] = "http://dev.example.com";
$config["www_root"] = "http://dev.example.com/";
$config["admin_root"] = "http://dev.example.com/admin/";

// To:
$config["domain"] = "http://www.example.com";
$config["www_root"] = "http://www.example.com/";
$config["admin_root"] = "http://www.example.com/admin/";

#52 General » The BigTree Bar » April 6, 2012 8:53am

benplum
Replies: 0

The BigTree bar is a front-end hook to the admin. When you are logged in as a BigTree user, a collapsible toolbar will be inserted into the site:

[img]http://www.bigtreecms.org/files/resources/discussion_btbar_open.jpg[/url]">
Users are presented with two basic options for interacting with the current page, 'Edit Content' and 'View in BigTree.' Clicking the 'Edit Content' button will trigger a modal window that replicates the 'Content' tab of the 'Edit Page' form:


Here users can directly edit the current page's content without leaving the page. Both options, "Save[/img]
[img]http://www.bigtreecms.org/files/resources/discussion_btbar_preview.jpg[/url]">
Clicking the 'View in BigTree' button should be self-explanatory, it simply takes the user to the "Edit Page[/img]
One thing to keep in mind when building your front end styles is that the BigTree bar is position: fixed and has a height of 40px. When the BigTree bar is opened, it will automatically add the class bigtree_bar_open as well as the inline style padding: 40px; to the  tag. If your site has any position: fixed; elements, like a fixed nav bar, simply style those elements accordingly:

#main_nav { left: 0; position: fixed; top: 0; width: 100%; }
.bigtree_bar_open #main_nav { top: 40px; }

#53 Re: Developer Help » Generated Route? » April 6, 2012 8:13am

That's probably the best way to learn, just remember to use a fresh install when moving into production!

The generated route field type doesn't conjure any sort of black magic, it's just a simple way to build search engine friendly URLs for your module-driven routed templates.

Lets say you're building a news module and each story contains a date, title, story and image. Begin by setting up a new database table with the columns 'date', 'title', 'story', 'image' and finally 'route'. Now head to the admin and start creating your new module. At the form creation screen, set the 'route' field type to "Generated Route".

Enter the database column name of the content that should be used when generated the route, in this case it would be the story's title. Click "Save".
Now when you create a new Story the title you enter will be transformed into a URL-ready string stored in the 'route' column. For example, "Breaking News!" will become "breaking-news". The real heavy lifting is done by a the field type processor (core/admin/field-types/process/route.php) and the internal function $cms->urlify("String"). This new string can now be used by the News module to link to a detail page where you query for a particular story:

#54 Developer Help » Working With Navigation » April 3, 2012 8:32am

benplum
Replies: 0

There are a few different navigation structures in BigTree that you can utilize in your sites:

Navigation refers to the hierarchical tree structure of BigTree pages. The Main Navigation, or Top Level Nav, are pages that are direct children of the Home page. Sub Nav are pages that are direct children of any other page.

Breadcrumbs provide a direct, sequential path from the current page to the homepage, tracing back the hierarchical tree structure.

Menus are not actually related to the hierarchical tree structure. Instead they are settings that allow you to group together random pages that aren't necessarily near each other in the page tree, or even external links.

Drawing the Main Nav
To access the Main Nav use $cms->getNavByParent(0, 2). The first parameter is the ID of the parent page, in this case 'Home,' while the second parameter is how many navigation levels to return, in this case 2. A constant value 0 as the function's $parent parameter will return the same result regardless of the page context. BigTree will return an array of every top-level page:

Array (
    [1] => Array (
            [id] => 1
            [parent] => 0
            [title] => About
            [route] => about
            [link] => http://example.com/about/
            [new_window] =>
            [children] => Array (
                    [3] => Array (
                            [id] => 3
                            [parent] => 1
                            [title] => History
                            [route] => about/history/
                            [link] => http://example.com/about/history/
                            [new_window] => true
                            [children] => Array()
                    )
            )
    )
    [2] => Array (
            [id] => 2
            [parent] => 0
            [title] => Store
            [route] => store
            [link] => http://example.com/store/
            [new_window] =>
            [children] => Array ()
    )
)

This result can then be used in your template:


   

  •             [url=[/url]
                       

           
        [/*] 
   
    [/list]

Because BigTree does not markup its output, you are free to structure your code however you see fit. This can be styled to produce something like the main navigation used on bigtreecms.org.



Drawing the Sub Nav
When drawing page-specific navigation, you may need to know the top-level ancestor of the current page. To get that value, use $cms->getTopLevelNavigationId(). This will give you the ID of the correct top-level page:

$top = $cms->getTopLevelNavigationId();
$navigation = $cms->getNavByParent($top, 4);
Use it in conjunction with the loop above to produce a subnav sidebar, similar to what you see in thedocumentation.

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.