create custom page

Discussion in 'Customization & add-ons' started by test test, Oct 14, 2015.

  1. test test

    test test New Member

    Joined:
    Oct 14, 2015
    Messages:
    16
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    In your controlled you can use this code to get access logs for user:
    PHP:
    $logs Am_Di::getInstance()->db->selectPage($total"select * from ?_access_log where user_id =?"Am_Di::getInstance()->auth->getUserId());
    foreach(
    $logs as $record){
    // create table with records. 

    }
  3. test test

    test test New Member

    Joined:
    Oct 14, 2015
    Messages:
    16
    Thank you alexander for your reply.

    But where to place this code??
    When I add for example
    PHP:
     $logs['time'];
    in front of
    PHP:
    $this->view->content=
    the page doesn't load.

    Thanks for your attention.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Can you copy & paste exact code which you are using?
  5. test test

    test test New Member

    Joined:
    Oct 14, 2015
    Messages:
    16
    Hi alexander

    I use the following code:
    PHP:
    <?php
    Am_Di
    ::getInstance()->hook->add(Am_Event::USER_MENU'myAddMenuItem');


    //$logs = Am_Di::getInstance()->db->selectPage($total, "select * from ?_access_log where user_id =?", Am_Di::getInstance()->auth->getUserId());


    function myAddMenuItem(Am_Event $event)
    {
        
    $menu $event->getMenu();
        
    $menu->addPage(
            array(
                
    'id' => 'usage-history',
                
    'controller' => 'my-page',
                
    'module' => 'default',
                
    'label' => "Usage History",
                
    'order' => 500,
                
    'uri' => 'usage-history',
        ));
    }



    class 
    MyPageController extends Am_Controller // a Zend_Controller_Action successor
    {
        function 
    indexAction()
        {
            
    $user $this->getDi()->user//currently authenticated customer or throws exception if no auth

            
    $this->view->title "Usage History";
            
    $this->view->content "contens";
            
    $this->view->display('layout.phtml');
        }
    }

    $am Am_Di::getInstance();
    $am->blocks->add(new Am_Block('member/usage-history/left''Block Title''13123'null'usage-history.phtml'9999));
    But this code only add the tab "Usage-History" and title "Usage History" and content "contents".
    I also want to change "my-page" in controller to "usage-history" because this appears in URL.

    I think I must use .phtml files in folder /application/default/views/member, But I have no idea about the contents of that file.

    Thanks for your help
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    You can change my-page to usage-history. Also you need to rename controller MyPageController to UsageHistoryController in this case.

    Controller show content that you supplied eg. "contens". You can put anything here.
    Please check code of existing controllers to get idea how it works.

    To display tables I recommend to use aMember grids
    http://www.amember.com/docs/API/Grid
  7. test test

    test test New Member

    Joined:
    Oct 14, 2015
    Messages:
    16
    Hi Caesar

    My block always add to dashboard tab how can i add that to my custom tab?

    Thanks

Share This Page