PHP inside PHP

Discussion in 'PHP' started by Financiallypoor, Aug 26, 2010.

  1. #1
    What I'm trying to do is exclude this item from 1 page and show it on all of the other pages. Inside this item I want to exclude part of it from showing on another page

    
    <?php if (!is_page('977') ) {
    echo '<div class="box">
    <h3>Share this post:</h3>
    <div class="social_icons">
    
    <p>';
    
    
    
    
     if(!is_front_page()) {
    
                            echo'        <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="FinanciallyPoor">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    
    <script type="text/javascript" src="http://tools.tipd.com/evb.js"></script>';
    
    };
    
    
    
    
    
    
    echo '<a class="after after-stumbleupon" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" alt="Stumble It!" target="_blank"></a>
    <a class="after after-digg" href="http://digg.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" title="Submit to Digg" target="_blank"></a>
    <a class="after after-facebook" href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>" rel="nofollow" title="Share on Facebook" target="_blank"></a>
    <a class="after after-del" href="http://delicious.com/save?url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>', 'delicious', 'toolbar=no,width=550,height=550'); return false;" title="Bookmark this post on del.icio.us"></a>
    <a class="after after-tumblr" <script type="text/javascript" src="http://pixelspread.com/js/tumblr.js"></script> <script type="text/javascript"> </script> <a href="javascript:;" onclick="Tumblr.pop();"></a>
    <a class="after after-reddit" href="http://reddit.com/submit" onclick="window.location = 'http://reddit.com/submit?url=' + encodeURIComponent(window.location); return false"></a>
    </p>
    </div>
    
    
    
    <div class="stayintheloop">
    
    
    
    <!-- AWeber Web Form Generator 3.0 -->
    <style type="text/css">
    #af-form-1315190949 .af-body .af-textWrap{width:98%;display:block;float:none;}
    #af-form-1315190949 .af-body .privacyPolicy{color:#000000;font-size:12px;font-family:, serif;}
    #af-form-1315190949 .af-body a{color:#000000;text-decoration:underline;font-style:normal;font-weight:normal;}
    #af-form-1315190949 .af-body input.text, #af-form-1315190949 .af-body textarea{background-color:#FCF6E0;border-color:#CCCCCC;border-width:2px;border-style:inset;color:#000000;text-decoration:none;font-style:normal;font-weight:bold;font-size:14px;font-family:inherit;}
    #af-form-1315190949 .af-body input.text:focus, #af-form-1315190949 .af-body textarea:focus{background-color:#FAF4E8;border-color:#B5B5B5;border-width:2px;border-style:inset;}
    #af-form-1315190949 .af-body label.previewLabel{display:block;float:none;text-align:left;width:auto;color:#000000;text-decoration:none;font-style:normal;font-weight:normal;font-size:inherit;font-family:inherit;}
    #af-form-1315190949 .af-body{background-repeat:no-repeat;background-position:inherit;background-image:url("https://s3.amazonaws.com/FinanciallyPoor/backform.jpg");color:#000000;font-size:12px;font-family:, serif;}
    #af-form-1315190949 .af-quirksMode{padding-right:px;padding-left:px;}
    #af-form-1315190949 .af-standards .af-element{padding-right:px;padding-left:px;}
    #af-form-1315190949 .buttonContainer input.submit{background-image:url("https://s3.amazonaws.com/FinanciallyPoor/button.jpg");color:#000000;text-decoration:none;font-style:normal;font-weight:normal;font-size:inherit;font-family:inherit;}
    #af-form-1315190949 .buttonContainer input.submit{width:auto;}
    #af-form-1315190949 .buttonContainer{text-align:center;}
    #af-form-1315190949 button,#af-form-1315190949 input,#af-form-1315190949 submit,#af-form-1315190949 textarea,#af-form-1315190949 select,#af-form-1315190949 label,#af-form-1315190949 optgroup,#af-form-1315190949 option{float:none;position:static;margin:0;}
    #af-form-1315190949 div{margin:0;}
    #af-form-1315190949 form,#af-form-1315190949 textarea,.af-form-wrapper,.af-form-close-button,#af-form-1315190949 img{float:none;color:inherit;position:static;background-color:none;border:none;margin:0;padding:0;}
    #af-form-1315190949 input,#af-form-1315190949 button,#af-form-1315190949 textarea,#af-form-1315190949 select{font-size:100%;}
    #af-form-1315190949 select,#af-form-1315190949 label,#af-form-1315190949 optgroup,#af-form-1315190949 option{padding:0;}
    #af-form-1315190949,#af-form-1315190949 .quirksMode{width:300px;}
    #af-form-1315190949.af-quirksMode{overflow-x:hidden;}
    #af-form-1315190949{background-color:transparent;border-color:inherit;border-width:none;border-style:none;}
    #af-form-1315190949{overflow:hidden;}
    .af-body .af-textWrap{text-align:left;}
    .af-body input.image{border:none!important;}
    .af-body input.submit,.af-body input.image,.af-form .af-element input.button{float:none!important;}
    .af-body input.text{width:100%;float:none;padding:2px!important;}
    .af-body.af-standards input.submit{padding:4px 12px;}
    .af-clear{clear:both;}
    .af-element label{text-align:left;display:block;float:left;}
    .af-element{padding:5px 0;}
    .af-form-wrapper{text-indent:0;}
    .af-form{text-align:left;margin:auto;}
    .af-quirksMode .af-element{padding-left:0!important;padding-right:0!important;}
    .lbl-right .af-element label{text-align:right;}
    body {
    }
    </style>
    <form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl"  >
    <div style="display: none;">
    <input type="hidden" name="meta_web_form_id" value="1315190949" />
    <input type="hidden" name="meta_split_id" value="" />
    <input type="hidden" name="listname" value="fpjumpstart" />
    <input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="redirect_14f056bf315a8413d102b941d16ae40b" />
    
    <input type="hidden" name="meta_adtracking" value="AfterpostPoorform" />
    <input type="hidden" name="meta_message" value="1" />
    <input type="hidden" name="meta_required" value="name,email" />
    
    <input type="hidden" name="meta_tooltip" value="email||What's your email?" />
    </div>
    <div id="af-form-1315190949" class="af-form"><div id="af-body-1315190949" class="af-body af-standards">
    <div class="af-element" style="text-align: Center;">
    <img src="https://s3.amazonaws.com/FinanciallyPoor/formheader.jpg" alt="New Graphic" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element" style="text-align: Center;">
    <img src="https://s3.amazonaws.com/FinanciallyPoor/Form.jpg" alt="New Graphic" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element">
    <label class="previewLabel" for="awf_field-9991838"></label>
    <div class="af-textWrap">
    <input id="awf_field-9991838" type="text" name="name" class="text" value="What name do you go by?"  tabindex="500" />
    </div>
    <div class="af-clear"></div></div>
    <div class="af-element">
    <label class="previewLabel" for="awf_field-9991842"></label>
    <div class="af-textWrap"><input class="text" id="awf_field-9991842" type="text" name="email" value="What's your email?" tabindex="501"  onfocus=" if (this.value == 'What\'s your email?') { this.value = ''; }" onblur="if (this.value == '') { this.value='What\'s your email?';} " />
    </div><div class="af-clear"></div>
    </div>
    <div class="af-element buttonContainer">
    <input name="submit" id="af-submit-image-1315190949" type="image" class="image" style="background: none;" alt="Submit Form" src="https://s3.amazonaws.com/FinanciallyPoor/button.jpg" tabindex="502" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element privacyPolicy" style="text-align: Center"><p><a title="Privacy Policy" href="http://www.aweber.com/permission.htm" target="_blank">We respect your email privacy</a></p>
    <div class="af-clear"></div>
    </div>
    </div>
    </div>
    <div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=jMyMrIycDJwsnA==" alt="" /></div>
    </form>
    <script type="text/javascript">
        <!--
        (function() {
            var IE = /*@cc_on!@*/false;
            if (!IE) { return; }
            if (document.compatMode && document.compatMode == 'BackCompat') {
                if (document.getElementById("af-form-1315190949")) {
                    document.getElementById("af-form-1315190949").className = 'af-form af-quirksMode';
                }
                if (document.getElementById("af-body-1315190949")) {
                    document.getElementById("af-body-1315190949").className = "af-body inline af-quirksMode";
                }
                if (document.getElementById("af-header-1315190949")) {
                    document.getElementById("af-header-1315190949").className = "af-header af-quirksMode";
                }
                if (document.getElementById("af-footer-1315190949")) {
                    document.getElementById("af-footer-1315190949").className = "af-footer af-quirksMode";
                }
            }
        })();
        -->
    </script>
    
    <!-- /AWeber Web Form Generator 3.0 -->
    
    
    
    
    </div>
    
    
    <div style="clear:both;"></div>
    </div>';}
    ?>
    
    Code (markup):
    I know it looks really messed up because I've been messing around with it alot. I made a big space between the php inside the php just to make it easier. Any help would be greatly appreciated.
     
    Financiallypoor, Aug 26, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    Just what are you trying to do?? There's syntax errors everywhere.
     
    Rainulf, Aug 26, 2010 IP
  3. Financiallypoor

    Financiallypoor Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Its like an author box at the end of a post on a blog. It also has social media sharing icons like twitter to share the post. I have to exclude the twitter icon from the home page because it doesn't work right on that page. So that's the inner php.

    The outer php I use to stop the whole box from showing on a certain private page. What happens is that when I added the outer php the only thing it does now is stop showing the whole box on the home page. It still shows up on the private page.
     
    Financiallypoor, Aug 26, 2010 IP
  4. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Your code was a mess, I tried cleaning up some of the errors.

    I'm guessing you wanted the is_front_page() function?

    Also you dont need to use a php tag if it is already in an echo for example
    echo '<a class="after after-digg" href="http://digg.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" title="Submit to Digg" target="_blank"></a>';
    PHP:
    would be
    echo '<a class="after after-digg" href="http://digg.com/submit?url='.the_permalink().'&title='.the_title().'" rel="nofollow" title="Submit to Digg" target="_blank"></a>';
    PHP:
    I just got rid of the echos

    here ya go, give this a try:
    
    <?php
    function is_front_page(){
       if($_SERVER['REQUEST_URI']=='/' || $_SERVER['REQUEST_URI']=='/index.php'){
       return(1);
       }else{
       return(null);
       }
    }
    
    if (!is_page('977') ) {
    }
    echo '<div class="box">
    <h3>Share this post:</h3>
    <div class="social_icons">
    
    <p>';
    
    
    
     if(!is_front_page()) {
    ?>
            <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="FinanciallyPoor">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    
    <script type="text/javascript" src="http://tools.tipd.com/evb.js"></script>
    
    <?php }else{ ?>
    
    
    
    <div>
    <p>
    <a class="after after-stumbleupon" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" title="Stumble It!" target="_blank"></a>
    <a class="after after-digg" href="http://digg.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" rel="nofollow" title="Submit to Digg" target="_blank"></a>
    <a class="after after-facebook" href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>" rel="nofollow" title="Share on Facebook" target="_blank"></a>
    <a class="after after-del" href="http://delicious.com/save?url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>', 'delicious', 'toolbar=no,width=550,height=550'); return false;" title="Bookmark this post on del.icio.us"></a>
    <a class="after after-tumblr" <script type="text/javascript" src="http://pixelspread.com/js/tumblr.js"></script> onclick="Tumblr.pop();"></a>
    <a class="after after-reddit" href="http://reddit.com/submit" onclick="window.location = 'http://reddit.com/submit?url=' + encodeURIComponent(window.location); return false"></a>
    </p>
    
    
    
    
    <div class="stayintheloop">
    
    
    
    <!-- AWeber Web Form Generator 3.0 -->
    <style type="text/css">
    #af-form-1315190949 .af-body .af-textWrap{width:98%;display:block;float:none;}
    #af-form-1315190949 .af-body .privacyPolicy{color:#000000;font-size:12px;font-family: serif;}
    #af-form-1315190949 .af-body a{color:#000000;text-decoration:underline;font-style:normal;font-weight:normal;}
    #af-form-1315190949 .af-body input.text, #af-form-1315190949 .af-body textarea{background-color:#FCF6E0;border-color:#CCCCCC;border-width:2px;border-style:inset;color:#000000;text-decoration:none;font-style:normal;font-weight:bold;font-size:14px;font-family:inherit;}
    #af-form-1315190949 .af-body input.text:focus, #af-form-1315190949 .af-body textarea:focus{background-color:#FAF4E8;border-color:#B5B5B5;border-width:2px;border-style:inset;}
    #af-form-1315190949 .af-body label.previewLabel{display:block;float:none;text-align:left;width:auto;color:#000000;text-decoration:none;font-style:normal;font-weight:normal;font-size:inherit;font-family:inherit;}
    #af-form-1315190949 .af-body{background-repeat:no-repeat;background-position:inherit;background-image:url("https://s3.amazonaws.com/FinanciallyPoor/backform.jpg");color:#000000;font-size:12px;font-family: serif;}
    #af-form-1315190949 .af-quirksMode{padding-right:0px;padding-left:0px;}
    #af-form-1315190949 .af-standards .af-element{padding-right:0px;padding-left:0px;}
    #af-form-1315190949 .buttonContainer input.submit{background-image:url("https://s3.amazonaws.com/FinanciallyPoor/button.jpg");color:#000000;text-decoration:none;font-style:normal;font-weight:normal;font-size:inherit;font-family:inherit;}
    #af-form-1315190949 .buttonContainer input.submit{width:auto;}
    #af-form-1315190949 .buttonContainer{text-align:center;}
    #af-form-1315190949 button,#af-form-1315190949 input,#af-form-1315190949 submit,#af-form-1315190949 textarea,#af-form-1315190949 select,#af-form-1315190949 label,#af-form-1315190949 optgroup,#af-form-1315190949 option{float:none;position:static;margin:0;}
    #af-form-1315190949 div{margin:0;}
    #af-form-1315190949 form,#af-form-1315190949 textarea,.af-form-wrapper,.af-form-close-button,#af-form-1315190949 img{float:none;color:inherit;position:static;background-color:transparent;border:none;margin:0px;padding:0px;}
    #af-form-1315190949 input,#af-form-1315190949 button,#af-form-1315190949 textarea,#af-form-1315190949 select{font-size:100%;}
    #af-form-1315190949 select,#af-form-1315190949 label,#af-form-1315190949 optgroup,#af-form-1315190949 option{padding:0;}
    #af-form-1315190949,#af-form-1315190949 .quirksMode{width:300px;}
    #af-form-1315190949.af-quirksMode{overflow-x:hidden;}
    #af-form-1315190949{background-color:transparent;border-color:inherit;border-width:0px;border-style:none;}
    #af-form-1315190949{overflow:hidden;}
    .af-body .af-textWrap{text-align:left;}
    .af-body input.image{border:none!important;}
    .af-body input.submit,.af-body input.image,.af-form .af-element input.button{float:none!important;}
    .af-body input.text{width:100%;float:none;padding:2px!important;}
    .af-body.af-standards input.submit{padding:4px 12px;}
    .af-clear{clear:both;}
    .af-element label{text-align:left;display:block;float:left;}
    .af-element{padding:5px 0;}
    .af-form-wrapper{text-indent:0;}
    .af-form{text-align:left;margin:auto;}
    .af-quirksMode .af-element{padding-left:0!important;padding-right:0!important;}
    .lbl-right .af-element label{text-align:right;}
    body {
    }
    </style>
    <form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl"  >
    <div style="display: none;">
    <input type="hidden" name="meta_web_form_id" value="1315190949" />
    <input type="hidden" name="meta_split_id" value="" />
    <input type="hidden" name="listname" value="fpjumpstart" />
    <input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="redirect_14f056bf315a8413d102b941d16ae40b" />
    
    <input type="hidden" name="meta_adtracking" value="AfterpostPoorform" />
    <input type="hidden" name="meta_message" value="1" />
    <input type="hidden" name="meta_required" value="name,email" />
    
    <input type="hidden" name="meta_tooltip" value="email||What's your email?" />
    </div>
    <div id="af-form-1315190949" class="af-form"><div id="af-body-1315190949" class="af-body af-standards">
    <div class="af-element" style="text-align: Center;">
    <img src="https://s3.amazonaws.com/FinanciallyPoor/formheader.jpg" alt="New Graphic" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element" style="text-align: Center;">
    <img src="https://s3.amazonaws.com/FinanciallyPoor/Form.jpg" alt="New Graphic" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element">
    <label class="previewLabel" for="awf_field-9991838"></label>
    <div class="af-textWrap">
    <input id="awf_field-9991838" type="text" name="name" class="text" value="What name do you go by?"  tabindex="500" />
    </div>
    <div class="af-clear"></div></div>
    <div class="af-element">
    <label class="previewLabel" for="awf_field-9991842"></label>
    <div class="af-textWrap"><input class="text" id="awf_field-9991842" type="text" name="email" value="What's your email?" tabindex="501"  onfocus=" if (this.value == 'What\'s your email?') { this.value = ''; }" onblur="if (this.value == '') { this.value='What\'s your email?';} " />
    </div><div class="af-clear"></div>
    </div>
    <div class="af-element buttonContainer">
    <input name="submit" id="af-submit-image-1315190949" type="image" class="image" style="background: none;" alt="Submit Form" src="https://s3.amazonaws.com/FinanciallyPoor/button.jpg" tabindex="502" />
    <div class="af-clear"></div>
    </div>
    <div class="af-element privacyPolicy" style="text-align: Center"><p><a title="Privacy Policy" href="http://www.aweber.com/permission.htm" target="_blank">We respect your email privacy</a></p>
    <div class="af-clear"></div>
    </div>
    </div>
    </div>
    <div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=jMyMrIycDJwsnA==" alt="" /></div>
    </form>
    <script type="text/javascript">
        <!--
        (function() {
            var IE = /*@cc_on!@*/false;
            if (!IE) { return; }
            if (document.compatMode && document.compatMode == 'BackCompat') {
                if (document.getElementById("af-form-1315190949")) {
                    document.getElementById("af-form-1315190949").className = 'af-form af-quirksMode';
                }
                if (document.getElementById("af-body-1315190949")) {
                    document.getElementById("af-body-1315190949").className = "af-body inline af-quirksMode";
                }
                if (document.getElementById("af-header-1315190949")) {
                    document.getElementById("af-header-1315190949").className = "af-header af-quirksMode";
                }
                if (document.getElementById("af-footer-1315190949")) {
                    document.getElementById("af-footer-1315190949").className = "af-footer af-quirksMode";
                }
            }
        })();
        -->
    </script>
    
    <!-- /AWeber Web Form Generator 3.0 -->
    
    
    
    
    </div>
    
    
    <div style="clear:both;"></div>
    </div>
    <?php } ?>
    
    
    PHP:
    Hope that helped
    Cheers!
     
    Last edited: Aug 26, 2010
    Narrator, Aug 26, 2010 IP
  5. CaNeRiuM

    CaNeRiuM Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks information
     
    CaNeRiuM, Aug 27, 2010 IP
  6. Financiallypoor

    Financiallypoor Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It does everything right except nothing shows up on the front page. So it almost works. Any ideas on what would fix that?
     
    Financiallypoor, Aug 27, 2010 IP