Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

echo

y2kbgy2kbg New
edited January 2007 in Vanilla 1.0 Help
well i guess this is directed to wallphone becase it came from one of his extensions.
echo '<ul><b>'.$this->Context->GetDefinition('Friends_RecievedRequest').'</b><li id="AcceptFormPrecursor"><a onClick="document.getElementById(\'FriendAcceptSubmit\').style.display = \'list-item\'; document.getElementById(\'AcceptFormPrecursor\').style.display = \'none\';">' . $this->Context->GetDefinition('AcceptFriend') . '</a></li>'; echo '<li id="FriendAcceptSubmit" style="display: none"><form id="frmFriendAccept" method="post" action="' . GetUrl($this->Context->Configuration, 'account.php', '', 'u', ForceIncomingInt('u', $this->Context->Session->UserID)) . '">'; echo '<p><input type="hidden" value="' . ForceIncomingInt('u', $this->Context->Session->UserID) . '" name="friendid" /><input type="submit" value="'.$this->Context->GetDefinition('AreYouForSure').'" /></form> <a onClick="document.getElementById(\'FriendAcceptSubmit\').style.display = \'none\'; document.getElementById(\'AcceptFormPrecursor\').style.display = \'list-item\';">' . 'Cancel' . '</a></p></li></ul>';

Why do you use three echos? is it so it can be read by looking at php source but it would be on one line when viewing html source? what would be the purpose of that?

Comments

  • ZiyphrZiyphr New
    edited January 2007
    I used to use echos, it's easy to get lazy and use them but imho it's best practice to come in and out of php instead - especially for readability in text editors. This way no HTML is ever part of a string, e.g.

    <?php foreach ($row as $item) { ?> <div class="thing"> This is item is called <?=$item['title']?>. </div><?php } ?>

    Echos are used all over the place in Vanilla, is there a beneficial reason for this?
  • There are debates all over the internet whether it's more efficient or better practice to use echos, prints, or spaghetti code (coming in and out of php). Most testing comes to the conclusion that it makes very little difference performance wise and therefore it's largely down to the personal preference of the coder...
  • well since this part of an extension i don't think i could go in and out of php.
    I was actually just wondering why he uses 3 echos instead of 1 big one.
  • *Scratches head*

    I usually don't notice if I am using unnecessary echos. You can go in and out of PHP any time you want, in a loop or whatever, but I try to avoid it because I find the <?php ?> brackets are so hard to type.

    I suppose a reason to do this would be to make it easier to cut and paste snippets to move them around. Just make sure each echo belongs to its own opening and closing XHTML element.

    But what really confuses me is why that code is from your friends extension?
  • y2kbgy2kbg New
    edited January 2007
    haha if you read the first comment in in Friends Extension Discussion gave you credit for that reason. If you don't want me using your code I guess I will have to change it.
    here is the Credits table i made up:
    Thanks To:
    NameAliasWhy they deserve thanks
     silent1643Original Idea (Via AddOn request in forum)
    Joe Clarejoefor code to display user information in an orderly fashion (members page extension)
    Adam AtlasPolfor code to diplay link and write to data base (based on pol's userWallextension)
    Gerrard CowburnMiniSweeperfor idea on how to store friend data in userbase (via forum) also conformation that each user has a userID (lol)
    Alex MarshalliambigredLearn how to make settings page from annoucement extension.



    EDIT: Dang every time I think of the "Wall Extension" I think you, wallphone, was the creator. oops so this question was actually meant for pol then I guess.

This discussion has been closed.