Limit Find Fields/ Options

A place for users and developers of the Xataface to discuss and receive support.

Postby shannah » Fri Jan 26, 2007 4:41 pm

Hi Mike,

Unfortunately you can't easily put the valuelist in your Dataface_Application_Menu.html file, because it is only a template. You need to be able to extract the valuelist using PHP. Hence, you will need to either fill in a block (http://framework.weblite.ca/documentation/tutorial/customizing-the-dataface-look-and-feel/customizing) e.g. 'before_left_column' using the delegate class, or by creating a custom action as described above.

Best regards

STeve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby moj0rising » Mon Jan 29, 2007 5:08 pm

OK. My co-worker over here actually got the drop-down menus working! I'll explain how he got that together later for everyones reference.

And then I had to mess it all up...

I did a very dumb thing -- in trying to get the menus to display just right. I changed the file name he was using Dataface_Application_Menu2.html to left_slot.html and changed the fill_slot name="left_column" line to fill_slot name="left_slot" and nothing appeared on the web page at all after that change. When we put everything back the way it was, the site looked as if there was nothing in the left side of the screen -- as if there was no Dataface_Application_Menu2.html or Dataface_Application_Menu.html file present at all. The menu is gone!

If we go to http://10.0.3.69/torpedo/index.php/?-action=my_action , we see the menu on the left side like we should but if we click "submit query," it goes away.

I'm not sure what I could have done to cause this or how to fix it. What should we do?

Mike
moj0rising
 
Posts: 26
Joined: Wed Dec 31, 1969 5:00 pm

Postby moj0rising » Tue Jan 30, 2007 12:21 am

The custom action does not seem to get us anywhere -- I get empty drop-down menus. Not really sure why. I *think* I set it up just like your example (a few tries) but there must be something wrong. :(

It seems the block is a good option for now -- we'll need to have a page dedicated to search later. The only thing is. We're a little fuzzy on exactly how to work with that part (I have read the block tutorial a few times but still have some questions). In using blocks, exactly which file does the code go into and how? Can you show an example of a block in a file?

Here's one of several attempts to make use of the block feature:
bmmcom@bmm.com [~/public_html/torpedo/conf]# cat ApplicationDelegate.php
getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
// if the user is null then nobody is logged in... no access.
// This will force a login prompt.
$role = $user->val('Role');
return Dataface_PermissionsTool::getRolePermissions($role);
// Returns all of the permissions for the user's current role.
}


}

class tables_departments{
function block__before_application_menu(){

$app =& Dataface_Application::getInstance();

$query =& $app->getQuery();

$table =& Dataface_Table::loadTable($query['-table']);

$statusoptions= $table->getValuelist('Status');


$options = $table->getValuelist('Jurisdiction');

df_display(array('Jurs'=>$options,'Sta'=>$statusoptions), 'Dataface_Application_Menu2.html');
}
}
?>
"

I did actually get the application on the web. The URL is http://70.98.54.35/~bmmcom/torpedo/ . A user ID is nevada with a password of dataface.


Thanks again!

Mike
moj0rising
 
Posts: 26
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jan 30, 2007 2:58 am

It looks like your code is correct except for the fact that you have the block code inside a class named tables_departments. The above was a readout for the application delegate class, correct?

Your application delegate class file (ApplicationDelegate.php) should contain a single class 'conf_ApplicationDelegate'. All methods go in there.

e.g.:

class conf_ApplicationDelegate {

function getPermissions(&$record){
...
}


function block__before_application_menu(){
echo "here is some test text - start up the application and
you will see me about the application menu
in the left column.";

}
}


See a list of all of the blocks available in the main template at http://lamp.weblite.ca/dataface-0.6/docs/index.php?-table=SmartyTemplates&-action=browse&SmartyTemplateID=%3D55

Hope this helps.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby generatedname » Tue Jan 30, 2007 10:12 am

It looks like your code is correct except for the fact that you have the block code inside a class named tables_departments. The above was a readout for the application delegate class, correct?

>

Your application delegate class file (ApplicationDelegate.php) should contain a single class 'conf_ApplicationDelegate'. All methods go in there.

>

e.g.:

>

class conf_ApplicationDelegate {

>

function getPermissions(&$record){

> ...

}

>



> function block__before_application_menu(){

echo "here is some test text - start up the application and

> you will see me about the application menu

in the left column.";

>

}

>}



>

See a list of all of the blocks available in the main template at http://lamp.weblite.ca/dataface-0.6/docs/index.php?-table=SmartyTemplates&-action=browse&SmartyTemplateID=%3D55

>

Hope this helps.

>

-Steve



This is what I had originally in the delegate class, however it was not showing up in the block, so I took the idea for a new class from another example using class table_departments. As expected, this did not work either.
generatedname
 
Posts: 53
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jan 30, 2007 11:25 am

The code above works for me. Don't know what to suggest at this point except if you can give me FTP access I can take a look.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby generatedname » Tue Jan 30, 2007 12:38 pm

Yea, must have been a bad day for coding, or something. I scrapped the whole delegate class and rewrote it. Now the page loads fine. Must have had too many braces or missing one or some other monday detail. Thanks again for the help, now I'm working on other tweaks for application flow and look&feel. See what I can come up with. Great library you got here btw. Thanks again for your time, and putting this together. I may have more questions on this board later of things don't go at least 70% good =)

-Kurtis
generatedname
 
Posts: 53
Joined: Wed Dec 31, 1969 5:00 pm

Postby generatedname » Tue Jan 30, 2007 12:46 pm

OK, already have my first new question for you. I've been trying to search through the DF to find the login action. What I need to know is how to control what template gets loaded after login.

What I'm trying to get:

User goes to web page, first screen is the login screen. Then submitting login information will send them to a new template (I'm calling it First_Page_Template.html). And this template has the search action that this whole thread has been about. Once they submit their first search, it takes them to the Dataface_Main_Template.html which is all set up and ready to go.



Right now, I have the default_action set to a new action I wrote that displays First_Page_Template.html. Then after they search two things can happen: They are redirected to the login screen if they are not logged in, or they are sent to the Dataface_Main_Template.html and it will show search results correctly.



So, I'm guessing I need to do away with my new action, and find where the login action directs the user to Dataface_Main_Template.html and change it to First_Page_Template.html.

I could be way off on this, its just a guess since I have not yet found it in the code.

Thanks again. I'll continue looking, but if you know off the top of your head it could save me some time.
generatedname
 
Posts: 53
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jan 30, 2007 12:57 pm

Good to hear the blocks are working.

Sounds like you are getting on the right track. One thing, with terminology, probably better to speak of actions rather than templates when it comes to talking about flow of control in the application. This is because templates can be reused in multiple actions. For example the Dataface_Main_Template.html is used in every single action in Dataface, even your own actions if you use the {use_macro} tag. Better to give your action a name (the action that displays your First_Page_Template.html template) and work from there.

e.g. The user logs in, they are directed to the 'home' action (which displays the First_Page_Template.html template) instead of the 'list' action as it normally would.

It seems to me that setting your 'home' (my working name for your custom action until I know what it is really called) as the default action should be sufficient to do what you want to do. You are able to control the redirect page after login explicitly using the -redirect GET parameter

e.g. yourapp/index.php?-action=login&-redirect=http://www.google.ca
Would redirect the user to google after a successful login.

If you are forming the url using PHP, you need to urlencode the redirect url.
e.g. $url = $app->url('-action=login').'&-redirect='.urlencode($_SERVER['REQUEST_URI']);

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby generatedname » Tue Jan 30, 2007 3:33 pm

Ok, I may have found a better way to ask.

For my "home" action, is there a way to check for login status? And say, if they are logged on then show my First_Page_Template.html, otherwise process login.
generatedname
 
Posts: 53
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jan 30, 2007 3:57 pm

First: Yes you can check the login status at any time by checking if the logged in user is null.
e.g.
Code: Select all
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !$user ) echo "User is not logged in";
else echo "User is logged in";


Second: It sounds like what you are trying to do is just assign permissions so that the user has to log in before he does anything. Is this correct?

If so, just set your permissions so that the user has to be logged in to receive access.
e.g.
Code: Select all
class conf_ApplicationDelegate {
   function getPermissions(&$record){
      $auth =& Dataface_AuthenticationTool::getInstance();
      $user =& $auth->getLoggedInUser();
      if ( !$user ) return Dataface_PermissionsTool::NO_ACCESS();
      else {
          return Dataface_PermissionsTool::ALL(); // or whatever you think the permissions should be
                // could also be things like Dataface_PermissionsTool::READ_ONLY();
      }

   }

...


If the permissions fail and the user is not logged in, then he will kicked to the login page. If he is logged in and permissions fail, then he will see a permission denied message.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby generatedname » Tue Jan 30, 2007 5:31 pm

I'll tell you what man, you are amazing.....

function handle(&$params) {

$auth =& Dataface_AuthenticationTool::getInstance();

$user =& $auth->getLoggedInUser();

if ( !$user ) df_display(array(),'Dataface_Login_Prompt.html');

else df_display(array(), 'Dataface_First_Page_Template.html');

}


I changed my home action to read that code exactly and BAM. works perfect. Thanks again Steve!


-Kurtis
generatedname
 
Posts: 53
Joined: Wed Dec 31, 1969 5:00 pm

Previous

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved