Skip to content

Code Generator

Using the Code Generator (CMS Setup > Code Generator), you can quickly create customized code for your index page and detail page viewers.

The Code Generator homepage lists the available generators as links: List Page, Detail Page, Combo Page, RSS Feed, and Category Menu. Click a generator to open its options page, where you choose a section from the Select Section dropdown and configure the generator’s options.

  1. Click the List Page generator link to show a list of one or more records
  2. From the Select Section dropdown, choose News
  3. Configure the Viewer Options for the News index. For example, select “Show # records per page…” and specify a number such as 5
  4. Click the Show Code button to generate the PHP code

The List Page generator is suitable for news, blogs, FAQs, quotes, job listings, and similar sections.

  1. Click the Detail Page generator link to show details about a single record
  2. From the Select Section dropdown, choose News
  3. Configure the Viewer Options for the News detail page
  4. Click the Show Code button to generate the PHP code

The Detail Page generator works for a news story, blog post, featured client, About Us page, contact page, and similar pages.

How Many:

  • Show all records on one page
  • Show the first # records only
  • Show # records per page with prev & next page links

Record Sorting:

  • Default — uses the same sorting as the editor (recommended)
  • Random — show records in random order

Show Uploads:

  • Show all uploads
  • Show # uploads
  • Don’t show uploads

Allow Searching — filter results based on search form input (disable for multiple viewers on one page)

Expert Mode — don’t show instructions or extra HTML in generated code. This checkbox appears on every generator, and the setting is remembered per browser.

Which Record:

  • Single record sections: load the first record in the database
  • Multi record sections: get the record # from the end of the URL (e.g., viewer.php?record_title-3)
  • Custom: load a specific record #

Show Uploads — same show all / show # / don’t show options as the List Page generator

The Combo Page generator creates a single page that handles both views: a list of links to records, and full details for the currently selected record.

Select Section — the section to generate the viewer for

How Many:

  • Show all records
  • Show the first # records only

Title/Name field — the field used as the link text for each record in the list. The dropdown loads the chosen section’s text field, text box, and WYSIWYG fields.

Show Uploads — same show all / show # / don’t show options as the List Page generator; applies to the detail record

Select Section — the section to generate the feed from

How Many:

  • Show all records
  • Show the first # records only

Feed Title / Feed Link / Feed Description / Feed Language — the feed’s channel details: name, website URL, description, and language code (e.g., en-us). All four are required.

Title field and Description field — the fields used for each item’s title and description; both required. The dropdowns load from the chosen section’s text field, text box, and WYSIWYG fields.

Select Section — only category sections are listed

Category Format:

  • Show All
  • One Level
  • Two Level
  • Breadcrumb

Output HTML Style:

  • Unordered List (UL, LI tags)
  • Indented Text

Default Category:

  • None — no category will be selected
  • First — the first category will be selected
  • Category — a specific category you choose will be selected

Category Root (under Advanced Options) — for menu branches; only categories below this one will be displayed

Clicking Show Code on any generator opens the Show Code page, which displays the generated PHP code.

Save the code and modify it to match your site design. The page’s instructions suggest a filename of the form {table}-{suffix}.php (for example, blog-list.php for a List Page), but you can choose your own name. The generated page is plain by default to make it easier to drop the code into an existing site template.

Next, upload the file to your desired location on the site. For example, you might upload to: http://www.example.com/blog.php

Once you’ve saved and uploaded your generated code, update the Viewer URLs for the corresponding section (the Show Code page’s instructions link there directly):

  1. Navigate to CMS Setup > Database Editor
  2. Select the modify option for your section (for example, Blog)
  3. Click the Viewers tab on that page
  4. Enter the URL where you uploaded the generated code

This lets the program know where the pages are located.

Documents CMS Builder 3.83