SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Understanding the basics

    Hi Happy new year to you all!

    Im learning php...I havent gotten my head around something and was hoping a pro could explain or help...

    This is my code I have to insert into my website (joomla) index.php...
    PHP Code:
    <?php
    require_once('37603303e9f36186bcc6bac.php');
    $voltRank = new VoltRank();
    echo 
    $voltRank->display();
    ?>
    Ok What I am trying to achieve:

    This code displays on ALL my pages, therefore I want it to display on only this page: http://www.insight-design.co.za/inde...d=48&Itemid=43

    (Excuse the long url?...)

    What I thaught is to add an if statement, but please can someone show this girl how to do this?...makes sense?

    Thanks

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In Joomla you should not (at least I don't recommend) add any custom codes directly index.php file. Instead you should develop simple extension (possibly a system plugin for your purpose I guess, or a module) so that your code does not overwritten when you upgrade Joomla later on. Otherwise though I am not sure what exactly the function does, you can even place it on the template file as well. If it displays something then develop a simple module and install it to a position in the current template.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know you shouldn't add code for when things get upgraded...I simply needed the help with the code, to learn php

    thanks

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Rajugs answer covers it, but seeing as you still ask:

    if the incoming url contains the url arguments, using the GET method in the url string

    ?option=com_content&view=article&id=48&Itemid=43

    And you have something that should only show up when those exact values appear, you would add this conditional check:

    PHP Code:
    if( $_GET['option'] == 'com_content' 
     
    && $_GET['view'] == 'article'
     
    && $_GET['id'] == 48
     
    && $_GET['Itemid'] == 43 ){

    // do something special


    In fact it is worse than that, you'd also have to have previously checked each of those $_GET keys was set to stop loads of warnings appearing in your log files and potentially on your site if one or more of them was not set.

    PHP Code:
    if( isset($_GET['option'] ) && // and so on 
    You are best off getting as close as you can to the template which governs the behaviour of this particular set of pages (articles?) and just check for the existence of say, id : 48
    PHP Code:
    f( isset($_GET['id'] ) && $_GET['id'] == 48 ){

    // do something special


    There may well be a Jommla-esque way of doing what you want, you could seek out Joomla users to ask them.

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, both comments helped me in my coding thanks for your support

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have another code question...if somone is around

    In my joomla website I need to create some funny custom "prize-image designed with links to different pages" where the prizes are...very silly but its what the client wants....all people have to log in first....

    What I need is that once a certain user is on the main page and clicks to the next page, he IS NOT ALLOWED to go back to the main page...so I need some sort of code that will be inserted into the article, not allowing the user to go back to the page....

    Please can anyone of the gurus help. Thank you Cups

  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Skye1 View Post
    What I need is that once a certain user is on the main page and clicks to the next page, he IS NOT ALLOWED to go back to the main page...so I need some sort of code that will be inserted into the article, not allowing the user to go back to the page....
    I think you are developer you must know that you cannot insert any codes in the articles. So that has to be done via code and possibly with your controllable component or module/plugin. The idea would be to store the visited page numbers (I would assign numbers to each step or page) in session/cookie and check if he/she current page is less than the maximum reached page number then always redirect or give some warning/error message to the user.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  8. #8
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If someone wants to go back to the home page, they will workaround any kludge you try and fix up.

    Might be better to instantiate a session when they arrive on the home page, show them the link.

    Set a session variable:
    PHP Code:
    $_SESSION['visited_home_page'] = true
    When they go back to the home page, do not show the link if that session variable is set.

    Even then, all they have to do is open a new browser session and revisit the home page with a new empty session, this might satisfy your client.

    *Edit, actually I think that is what Rajug just said -- never mind, I will leave this comment.

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URGENT <3

    Wow! Thanks fo the response!

    Better yet, I found this plugin after nights of research :which will allow me to add the code I need:

    http://www.metamodpro.com/metamod/re...ge-redirection

    Now I need to know what the right code is to inset to my page, let me give a clear explanation as I did not before...


    When any of my users to my website falls on THIS page:http://topplacestravel.co.za/index.php/quiz-pop (via a url sent to their email box)

    When they navigate AWAY from this page they wont be allowed to view that page again, therefore each user is restricted to only view the page ONCE -make more sense?

    This is exactly what I need. Please can someone help???

  10. #10
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you are developer you must know that you cannot insert any codes in the articles. So that has to be done via code and possibly with your controllable component or module/plugin.
    You are quite right, I have found a plugin thank you

  11. #11
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Skye1 View Post
    When any of my users to my website falls on THIS page:http://topplacestravel.co.za/index.php/quiz-pop (via a url sent to their email box)

    When they navigate AWAY from this page they wont be allowed to view that page again, therefore each user is restricted to only view the page ONCE -make more sense?
    What is your page? A file having .php extension or an article (if it is Joomla) having a separate menu is a page? In either case you have to track/store visited pages either in a session variable or cookie. If a page meant to be a Joomla article having a menu (Itemid) then you have to store Itemid or id (id of a content) once it is visited. And check the Itemid it is already visited. You need to write something like below code in a system plugin.
    PHP Code:
    if(!in_array(JRequest::getVar('Itemid'), $_SESSION['_visited_page']){
        
    $_SESSION['_visited_page'][] = JRequest::getVar('Itemid'0);
    }
    else{
        die(
    'Sorry you are allowed to visit this page only once!'); // or anything

    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  12. #12
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Thank you !!!!!

    Sorry, I have an ARTICLE http://topplacestravel.co.za/index.php/quiz-pop... I hope I understand...

    Do I need to use the id of this article then? ..and most important - can I use this code?

    Thanks
    God Bless!

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I am working on a tight deadline here...

    I have inserted your code into my article and also used a better plugin: http://extensions.joomla.org/extensi...9zY29uZmlnIjt9

    I inserted your code into my article http://topplacestravel.co.za/index.php/quiz-pop, but It did still allow me to enter the page

    What am I doing wrong? please help?

  14. #14
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I already told that PHP codes cannot be inserted directly into the article but you need to add the code in a plugin (possibly the system plugin and I presume you are quite aware of different types of plugins in Joomla since you are a Joomla developer). The code I gave above is just an idea how you can do to achieve the goal and you are the one to manage accordingly.

    I don't know what you have written, but when I tried to visit the page http://topplacestravel.co.za/index.php/quiz-pop I got the message 'You are not authorised to view this resource.'. What it should show? Is it the article to be shown on the page? If you are not a Joomla developer and cannot operate with Plugins then you have to hire someone to look in to it.

    Good luck!
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  15. #15
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    log in with

    name:corpt
    password:corpt

    Then you should see the article WHICH is only allowed to be seen ONCE. I have used a PLUGIN
    http://extensions.joomla.org/extensi...Y29uZmlnIjt9to allow php in an article and I am a Joomla developer



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •