Field Editor

24 posts by 2 authors in: Forums > CMS Builder
Last Post: December 27, 2007   (RSS)

By Dave - December 26, 2007

If you delete the second block, and set "$options['recordNum'] = $numFromUrl;" for the first, it should work?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Field Editor

By Djulia - December 26, 2007

$numFromUrl = getNumberFromEndOfUrl();
if (!$numFromUrl) { $numFromUrl = 5; }



1) Your solution functions.
But that answers partly the problem.

If Virginia delete recording 5, Jack must again edit file blogPage.php to modify the value of $numFromUrl.

It would be possible to use, for example, order ASC ?
Thus, the value would be the first recording found in the table.

2) If I delete the second block, I always have the same problem.
In fact in this case, it is the value of "$options['orderBy'] = 'ordre DESC, date DESC, title';" which is used.

Djulia


P.s. : Thank you for your patience.

By Dave - December 26, 2007

I think in the long run, it may be easier to look up the records by name instead of number. But it looks like it's always working the way it is, so here's how to do it as you requested. Try this at the top:

require_once "/xxx/viewer_functions.php";

// load menu items
$options = array();
$options['tableName'] = 'blog';
$options['titleField'] = 'title';
$options['viewerUrl'] = '/xxx/blogPage.php';
$options['perPage'] = '9999';
$options['orderBy'] = 'order DESC, date DESC, title';
$options['pageNum'] = '1';
$options['where'] = '';
$options['useSeoUrls'] = '1';
list($listRows, $listDetails) = getListRows($options);

// get record num for page content
$numFromUrl = getNumberFromEndOfUrl();
if (!$numFromUrl) {
$lastIndex = count($listRows) - 1;
$numFromUrl = $listRows[$lastIndex]['num']; // use default
}

// load page content
$options = array();
$options['tableName'] = 'blog';
$options['recordNum'] = $numFromUrl;
$options['where'] = '';
$record = getRecord($options);


It loads the list of record for your menu options as $listRows. And since those are already sorted by 'order DESC' (opposite of what you want) we just get the last one as the record number to use if no record number is specified in the url.

Let me know if that works the way you want. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Field Editor

By Djulia - December 26, 2007

I have an error message:

Page Viewer (blog) errors
Unknown option 'titleField' specified. Valid option names are: (tableName, recordNum, where)
Unknown option 'viewerUrl' specified. Valid option names are: (tableName, recordNum, where)
Unknown option 'perPage' specified. Valid option names are: (tableName, recordNum, where)
Unknown option 'orderBy' specified. Valid option names are: (tableName, recordNum, where)
Unknown option 'pageNum' specified. Valid option names are: (tableName, recordNum, where)
Unknown option 'useSeoUrls' specified. Valid option names are: (tableName, recordNum, where)


You have an idea ?

Thank you for your assistance.

Djulia

By Dave - December 26, 2007

It can get confusing when you have multiple viewers on one page. Some of the list options are being passed to the page viewer by accident. The simplest way to avoid that is to use different variable names for each type of options. Like this:

require_once "/xxx/viewer_functions.php";

// load menu items
$listOptions = array();
$listOptions['tableName'] = 'blog';
$listOptions['titleField'] = 'title';
$listOptions['viewerUrl'] = '/xxx/blogPage.php';
$listOptions['perPage'] = '9999';
$listOptions['orderBy'] = 'order DESC, date DESC, title';
$listOptions['pageNum'] = '1';
$listOptions['where'] = '';
$listOptions['useSeoUrls'] = '1';
list($listRows, $listDetails) = getListRows($listOptions);

// get record num for page content
$numFromUrl = getNumberFromEndOfUrl();
if (!$numFromUrl) {
$lastIndex = count($listRows) - 1;
$numFromUrl = $listRows[$lastIndex]['num']; // use default
}

// load page content
$pageOptions = array();
$pageOptions['tableName'] = 'blog';
$pageOptions['recordNum'] = $numFromUrl;
$pageOptions['where'] = '';
$record = getRecord($pageOptions);

Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Field Editor

By Djulia - December 26, 2007

That functions.
But, maintaining all the pages have the same recording.

In fact, they take the value of :
$listOptions['orderBy'] = 'order DESC, date DESC, title';

2 if 'order ASC' or 5 if 'order DESC'.

It is possible to correct this problem ?

Thank you,

Djulia

By Dave - December 26, 2007

So all the pages show the same record still?

It should be that the menu shows all the available pages and that the following urls display as follows:

blogPage.php (shows last page listed on menu, whatever the number)
blogPage.php/5 (shows record 5 - Home)
blogPage.php/4 (shows record 4 - Page1)
blogPage.php/3 (shows record 3 - Page2)
blogPage.php/2 (shows record 2 - Contact Us)

If that's not happening perhaps you can attach the blogPage.php again and I'll have a look.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Field Editor

By Djulia - December 26, 2007

In fact, if I place the menu after the block of the recording, the problem is solved.

<ul id="menu">
<?php $numFromUrl = getNumberFromEndOfUrl(); foreach ($listRows as $record): if ($record): ?>
<?php if ($record['num'] == $numFromUrl): ?>
<li><span id="menuselected"><?php echo $record['title'] ?></span></li>
<?php elseif ($numFromUrl == ""): ?>
<li><span id="menuselected"><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></span></li>
<?php else: ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endif ?>
<?php endif ?>
<?php endforeach ?>
</ul>



It seems that there is a conflict with the menu and the data of the recording.

Your opinion ?

Djulia

By Dave - December 26, 2007

Thanks. You're right, it was a bug of sorts. Here's how I got it working:

I got an error on my MySQL server (maybe not on yours) because 'order' was a reserved word. So I quoted it like this:

$listOptions['orderBy'] = '`order` ASC, date DESC, title';

The code that displays the menu also uses the $record variable. This overwrites the $record variable we define at the top of the script, so if we change it to something else like $listRecord, it works as intended.

<?php foreach ($listRows as $listRecord): if ($listRecord): ?>
... change all $record variables to $listRecord ...
<?php endif ?>
<?php endforeach ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com