Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Field Editor

 

 


Djulia
User

Dec 24, 2007, 2:08 AM

Post #1 of 24 (4523 views)
Shortcut
Field Editor Can't Post

Hi Dave,

I have two new questions.

1) It would be possible to place fields hidden (type="hidden") in Field Editor ?

Field Type : hidden

For example, I would like that the editor gives a value, but not the user.

2) My second question relates to the field list.

Field Type : list (pulldown)

a) When the user edit the page again, the value is not preserved.
The user must again select the value. It is a bug ?

b) It would be possible to apply the Unique option ?

Thank you for your assistance.

Djulia


(This post was edited by Djulia on Dec 24, 2007, 3:17 AM)


Dave
Staff / Moderator


Dec 24, 2007, 9:36 AM

Post #2 of 24 (4514 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

>1) It would be possible to place fields hidden (type="hidden") in Field Editor ?

Not right now, what would you like to use that for? Or what are you trying to achieve?

>Field Type : list (pulldown)
>a) When the user edit the page again, the value is not preserved. The user must again select the value. It is a bug ?

The value should be preserved, that's what happens when I test. Can you post some of your options so we can try and recreate the problem on our end? If we can recreate it we can fix it.

>b) It would be possible to apply the Unique option ?

We can add that feature, it would limit how many records you could have, though, to the number of list options. Because each record could only have one unique option.

Can I ask what you want to use that for?

Dave Edis - Senior Developer
interactivetools.com
 


Djulia
User

Dec 25, 2007, 2:41 PM

Post #3 of 24 (4462 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Hi Dave,

Here what I try to obtain

Admin == Jack
User == Virginia

Section == Admin > Section Editors > Add a new menu... > Blog

In Admin > Section Editors > modify (Blog) > Add Field :

Field Label == Order
Field Name == order
Field Type == list
Display As == pulldown
List Options == 1, 2, 3, 4

I created as administrator (Jack) in my Blog section :

Page 1 (order == 1)
Page 2 (order == 2)
Page 3 (order == 3)
Page 4 (order == 4)

Now, Virginia is connected on the Blog section.
Virginia can modify the order of the pages.
If Order were of hidden type, it would be possible to prohibit Virginia from modifying the order of the pages.

But, there is perhaps another solution that the use of a field hidden to prohibit the user (Virginia) from modifying a field ?

Question 2

It would be possible to prohibit the user (Virginia) to modify or delete a page in the section (Blog ) ?

Admin
Page 1 (order == 1) - modify
Page 2 (order == 2) - modify
Page 3 (order == 3) - modify
Page 4 (order == 4) - modify

User
Page 1 (order == 1) - no modify
Page 2 (order == 2) - modify
Page 3 (order == 3) - modify
Page 4 (order == 4) - modify

-----

You think that there is a possible solution ?

Thank you for your answer.

Djulia

Merry Xmas, and a Happy New Year Everyone Smile


Dave
Staff / Moderator


Dec 26, 2007, 10:16 AM

Post #4 of 24 (4421 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

Ok, I understand. There's no simple way to do that.

I could add features to limit on a menu by menu basis if users are allowed to "add" or "remove" records, but it would affect all users and you'd need to turn it on and off when you want to add/remove records again.

We can also add a feature "hidden" for fields where they won't display and will keep their value but it would be a global menu setting as well.

We plan to add more fine grained user access controls in future but that will take longer. If it would help I could add the features mentioned above much sooner.

Dave Edis - Senior Developer
interactivetools.com
 


Djulia
User

Dec 26, 2007, 10:53 AM

Post #5 of 24 (4417 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Hi Dave,

Thank you for your answer. Smile

An answer for question 2, would also give a solution for another problem.

By default blogPage.php (Page Viewer) takes value 1 ($options['recordNum'] = '';).

If the user (Virginia) delete the recording 1, blogPage.php (Page Viewer) uses the condition :

<?php if (empty($record)): ?>
No record found!<br/><br/>
<?php endif ?>

1) If the admin (Jack) can prohibit to delete page 1, it would be possible to preserve the value of ($options['recordNum'] = '';).

2) If not, how the user can indicate a value for ($options['recordNum'] = '';) without editing the code in blogPage.php (Page Viewer).

Thank you for your feedback.

Djulia


(This post was edited by Djulia on Dec 26, 2007, 11:35 AM)


Djulia
User

Dec 26, 2007, 11:25 AM

Post #6 of 24 (4412 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Would a suggestion, it be possible to use ($options['recordNum'] = 'order';) ?

Thank you for your feedback.

Djulia


Dave
Staff / Moderator


Dec 26, 2007, 11:53 AM

Post #7 of 24 (4407 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

If you wanted to show the first record that exists, sorted by order, you could use the list viewer to show just one record with these options


Code
$options['pageNum'] = '1'; 
$options['perPage'] = '1';
$options['orderBy'] = 'order';


What do you want displayed when the user visits blogPage.php?

Dave Edis - Senior Developer
interactivetools.com
 


Djulia
User

Dec 26, 2007, 12:57 PM

Post #8 of 24 (4404 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Thank you for your answer.

Here my project (Blog is a section).

Home - Record Number: 5 - /blogPage.php/Page_2-3 == (order 1)
Page 1 - Record Number: 4 - /blogPage.php/Page_1-4 == (order 2)
Page 2 - Record Number: 3 - /blogPage.php/Page_2-3 == (order 3)
Contact - Record Number: 2 - /blogPage.php/Contact-2 == (order 4)

Now, if the URL /blogPage.php is visited, it has the message : No record found !

It would be possible to have recording 5 (Home) ?

In my /blogPage.php file, I added $options['recordNum'] = '5'; line 61.
But all the pages have then this value.

Djulia

P.s. : You can delete the attached files, if it is not authorized on the forum.


(This post was edited by Djulia on Dec 26, 2007, 1:03 PM)
Attachments: Capture1.gif (42.9 KB)
  blogPage.php (5.83 KB)


Dave
Staff / Moderator


Dec 26, 2007, 2:20 PM

Post #9 of 24 (4395 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

Hey, nice design. :)

So, a few things. First off, the page viewer defaults to record 1 if no record is specified, so to use record 5 by default you can add some code like this at the top:


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


That will set $numFromUrl to the number on the end of the url or use 5 as the default. Then pass that to the list viewers as an option like this:


Code
$options['recordNum'] = $numFromUrl;


Give that a try and let me know if it works.

It looks like you have the block that calls getRecord() twice, you should be able to remove the second one.

Also, once you get it working, you can actually have the urls look like whatever you want. For example, they could be like this:


Code
blog.php (shows home) 
blog.php/home
blog.php/page1
blog.php/page2
blog.php/contact


And you could have a pulldown that specified what page type each record was. If you want help with that later let me know.

Dave Edis - Senior Developer
interactivetools.com
 

(This post was edited by Dave on Dec 26, 2007, 2:22 PM)


Djulia
User

Dec 26, 2007, 2:37 PM

Post #10 of 24 (4390 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post


In Reply To
It looks like you have the block that calls getRecord() twice, you should be able to remove the second one.



I wished to delete it, but that poses a problem.

All the pages give the same recording.

And if I delete the first, I cannot use <?php echo $record['title'] ?> for the title.

With is your opinion, it a bug ?

Djulia


Dave
Staff / Moderator


Dec 26, 2007, 2:42 PM

Post #11 of 24 (4388 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

If you delete the second block, and set "$options['recordNum'] = $numFromUrl;" for the first, it should work?

Dave Edis - Senior Developer
interactivetools.com
 


Djulia
User

Dec 26, 2007, 3:01 PM

Post #12 of 24 (4381 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post


Code
$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.


Dave
Staff / Moderator


Dec 26, 2007, 3:20 PM

Post #13 of 24 (4377 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

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:


Code
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
 


Djulia
User

Dec 26, 2007, 3:48 PM

Post #14 of 24 (4374 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

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


Dave
Staff / Moderator


Dec 26, 2007, 4:16 PM

Post #15 of 24 (4364 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

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:


Code
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
 


Djulia
User

Dec 26, 2007, 4:39 PM

Post #16 of 24 (4362 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

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


Dave
Staff / Moderator


Dec 26, 2007, 4:48 PM

Post #17 of 24 (4359 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

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
 


Djulia
User

Dec 26, 2007, 4:49 PM

Post #18 of 24 (4358 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

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


Code
   <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


Djulia
User

Dec 26, 2007, 5:07 PM

Post #19 of 24 (4350 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

> So all the pages show the same record still?
Yes

Here 2 files :
1 == blogPage-error.php
2 == blogPage-no-error.php

Djulia
Attachments: blogPage-error.php (4.15 KB)
  blogPage-no-error.php (4.15 KB)


Dave
Staff / Moderator


Dec 26, 2007, 6:02 PM

Post #20 of 24 (4342 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

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:


Code
$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.


Code
<?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
 


Djulia
User

Dec 27, 2007, 12:01 PM

Post #21 of 24 (4298 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Thank you Dave, your adaptation functions perfectly. Smile

Djulia


Dave
Staff / Moderator


Dec 27, 2007, 12:05 PM

Post #22 of 24 (4296 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

Whew, I'm glad to hear that! :)

After we release the next version I think I might write up a tutorial on how to do this so it's easier! :)

Dave Edis - Senior Developer
interactivetools.com
 


Djulia
User

Dec 27, 2007, 12:31 PM

Post #23 of 24 (4277 views)
Shortcut
Re: [Dave] Field Editor [In reply to] Can't Post

Hi Dave,


In Reply To
I could add features to limit on a menu by menu basis if users are allowed to "add" or "remove" records, but it would affect all users and you'd need to turn it on and off when you want to add/remove records again.

I use this solution, to prevent, that the recordings are deleted by the user.

in /lib/menus/default/list.php


Code
 <?php $username = $CURRENT_USER['username']; ?> 
<?php if ($username == 'admin'): ?>
<a href="javascript:confirmEraseRecord('<?php echo htmlspecialchars($menu) ?>','<?php echo $record{'num'} ?>');">erase</a>
<?php else: ?>
--
<?php endif ?>

But, it is not best solution, it would be better if it were possible to indicate only some recordings.

But, I am certain that you will find a solution for a future update. Wink

Djulia


Dave
Staff / Moderator


Dec 27, 2007, 1:14 PM

Post #24 of 24 (4240 views)
Shortcut
Re: [Djulia] Field Editor [In reply to] Can't Post

Yes there's a checkbox in the next version to disable erase for a section. So it's very easy to turn on and off. That's in the next version.

And further down the road we'll have more fine grained user access controls.

Dave Edis - Senior Developer
interactivetools.com