Change User side Dashboard

Discussion in 'Templates customization' started by microlinx, Nov 24, 2015.

Thread Status:
Not open for further replies.
  1. microlinx

    microlinx aMember Pro Customer

    Joined:
    Oct 26, 2004
    Messages:
    268
    I recall seeing something on how to do this, but can't locate it in the docs. Just trying to add either a text box or an embedded video into the user dashboard. See attached photo.

    Attached Files:

  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
  3. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    do you change left to right in the code caesar?
  4. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    i tried this to make a right and left

    //add new block at position member/main/right
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/right', 'google adverts', 'ad-R', null, 'renderMyBlock'));

    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs1 -->
    <ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-xxxxxxxxxxx"
    data-ad-slot="2848022103"
    data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></p>
    CUT;
    return $html;
    }

    //add new block at position member/main/left
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'google adverts', 'ad-L', null, 'renderMyBlock'));

    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs2 -->
    <ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-xxxxxxxxxxx"
    data-ad-slot="2848022103"
    data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></p>
    CUT;
    return $html;
    }

    but i then get a white screen on the whole, site, what did i miss?
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    It seems issue is same name for two functions. Just use different names and it should works eg.: renderMyBlock1 and renderMyBlock2

    Also you need to change name of function in block constructor eg.
    Am_Block('member/main/right', 'google adverts', 'ad-R', null, 'renderMyBlock1')

    By the way during development you can change aMmeber environment to debug to get more useful error messages
    http://www.amember.com/docs/Frequently_Asked_Questions#How_to_enable_more_verbose_error_messages
  6. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    so if on right

    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/right', 'google adverts', 'ad-R1', null, 'renderMyBlock1'));

    do i have to rename all the time the 3 parts? the ads, ad_r2 r3 ect and the block 1 2 3

    or can i somehow add 3 banner codes in one block?

    as this still gives a white screen

    //add new block at position member/main/right
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/right', 'google adverts', 'ad-R1', null, 'renderMyBlockR1'));

    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs1 -->
    <ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-3636828534890895"
    data-ad-slot="2848022103"
    data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    <br />
    <center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs2 -->
    <ins class="adsbygoogle"
    style="display:inline-block;width:300px;height:250px"
    data-ad-client="ca-pub-3636828534890895"
    data-ad-slot="6545100905"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></center></p>
    CUT;
    return $html;
    }

    //remove block with id member-main-unsubscribe
    Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');

    //add new block at position member/main/right
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'google adverts', 'ad-l1', null, 'renderMyBlockL1'));

    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs1 -->
    <ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-3636828534890895"
    data-ad-slot="2848022103"
    data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    <br />
    <center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs2 -->
    <ins class="adsbygoogle"
    style="display:inline-block;width:300px;height:250px"
    data-ad-client="ca-pub-3636828534890895"
    data-ad-slot="6545100905"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></center></p>
    CUT;
    return $html;
    }

    //remove block with id member-main-unsubscribe
    Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');

    i should be able to keep the tittles the same?
  7. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    Code:
    //add new block at position member/main/right
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/right', 'google adverts', 'ad-R1', null, 'renderMyBlockR1'));
    
    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs1 -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-3636828534890895"
         data-ad-slot="2848022103"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    <br />
    <center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs2 -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:300px;height:250px"
         data-ad-client="ca-pub-3636828534890895"
         data-ad-slot="6545100905"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></center></p>
    CUT;
    return $html;
    }
    
    //add new block at position member/main/right
    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'google adverts', 'ad-l1', null, 'renderMyBlockL1'));
    
    function renderMyBlock() {
    $html = <<<CUT
    <p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs1 -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-3636828534890895"
         data-ad-slot="2848022103"
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    <br />
    <center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- subs2 -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:300px;height:250px"
         data-ad-client="ca-pub-3636828534890895"
         data-ad-slot="6545100905"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script></center></p>
    CUT;
    return $html;
    }
    //remove block with id member-main-unsubscribe
    Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');
    Fatal error: Cannot redeclare renderMyBlock() (previously declared in /var/www/html/application/configs/site.php:127) in /var/www/html/application/configs/site.php on line 158
  8. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    if you can give me a example, for 5 blocks right, for banners be greatful
  9. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I mean you should not use function with same names. Just use different name for your function
    function renderMyBlock() {
  10. ccwjames

    ccwjames Member

    Joined:
    Sep 11, 2014
    Messages:
    430
    forgot to say thanks, sorted
  11. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I glad to hear it. You are welcome!
Thread Status:
Not open for further replies.

Share This Page