January 11, 201115 yr Hello, Well it seems yet another problem, Ive tried a few ways to solve it but surly somebody may have already found the solution here. Anyway, Im building a template system for my social network and it seems that the function is being executed before the template has been echoed out. <?php /* * * @Createdby: Shaun Childerley * @Version: 1.0.0 * @FileName: profiles.php * @Description: Displays user profiles. * @Date: 05/11/10 */ // A little homeing present.. if(!defined('SC_SEC')) { die(); } // Get the profile username $profileUsername = $shortcuts->get_value('username'); // Does the profile username exist? if($DBHandler->NumRows("SELECT * FROM sc_members WHERE username='$profileUsername'") < 1) { redirect('http://#/e/104'); exit(); } // If the profile exists, then fetch profile data and account permissions. $profileData = $DBHandler->FetchQuery("SELECT * FROM sc_members WHERE username='".$profileUsername."'"); $profilePerms = $DBHandler->FetchQuery("SELECT * FROM sc_permissions WHERE uid='".$profileData['id']."'"); $profileFriends = explode(' ', $profileData['friends']); $profileFriendrequests = explode(' ', $profileData['friendrequests']); // If the user is not a friend, check if profile cloak has been enabled. if(!in_array($accounts->data('id'), $profileFriends)) { if($profilePerms['perm_profilecloak'] == 1) { redirect('http://#/e/104'); exit(); } } // Load the default profile template $profileTemplate = file_get_contents('profiles/templates/icecold_blue/icecold_blue.tpl'); // Prepare profile data $profileTemplate = str_replace('<--PROFILE_FULLNAME-->', ucwords($profileData['firstname'].' '.$profileData['lastname']), $profileTemplate); $profileTemplate = str_replace('<--PROFILE_USERNAME-->', ucwords($profileData['username']), $profileTemplate); $profileTemplate = str_replace('<--PROFILE_EMAILADDRESS-->', $profileData['email'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_PHOTO-->', $profileData['profilephoto'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_TROPHIES-->', $profileData['trophies'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_TROPHIES-->', $profileData['trophieslost'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_HEALTH-->', $profileData['health'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_COINS-->', $profileData['coins'], $profileTemplate); $profileTemplate = str_replace('<--PROFILE_SEX-->', $profileData['sex'], $profileTemplate); //Prepare Profile Navaigation function profileNavigation() { global $profileData; //Menu items $profileNavigation = array( 'profile' => 'http://#/p/'.$profileData['username'], 'photos' => 'http://#/p/'.$profileData['username'].'/photos.html', 'videos' => 'http://#/p/'.$profileData['username'].'/videos.html', 'music' => 'http://#/p/'.$profileData['username'].'/music.html', 'friends' => 'http://#/p/'.$profileData['username'].'/friends.html', 'games' => 'http://#/p/'.$profileData['username'].'/games.html', ); //Spawn the menu items foreach($profileNavigation AS $item => $link) { echo '<a class="profilenavigation_link" href="'.$link.'">'.$item.'</a>';}} $profileTemplate = str_replace('<--PROFILE_NAVIGATION-->', profileNavigation(), $profileTemplate); // Prepare emotions $profileTemplate = str_replace('', '<img src="http://#/core/global_images/smilys/emoticon_tongue.png" alt="Tongue">', $profileTemplate); $profileTemplate = str_replace('', '<img src="http://#/core/global_images/smilys/emoticon_wink.png" alt="Wink">', $profileTemplate); $profileTemplate = str_replace('', '<img src="http://#/core/global_images/smilys/emoticon_unhappy.png" alt="Unhappy">', $profileTemplate); $profileTemplate = str_replace('', '<img src="#/core/global_images/smilys/emoticon_grin.png" alt="Grin">', $profileTemplate); $profileTemplate = str_replace('', '<img src="#/core/global_images/smilys/emoticon_smile.png" alt="Smile">', $profileTemplate); $profileTemplate = str_replace('', '<img src="http://#/core/global_images/smilys/emoticon_surprised.png" alt="Surprised">', $profileTemplate); //Parse the template echo $profileTemplate; ?> The template: <!-- * * @Createdby: Shaun Childerley * @Version: 1.0.0 * @FileName: Icecold_blue * @Description: Default Profile Template * @Date: 10/01/2011 * --> <style type="text/css"> #template_wrapper { position:relative; margin: 0 auto; width:829px; margin-top:10px; }#template_header { float:left; width:829px; height:73px; background:url(http://#/profiles/templates/icecold_blue/global_images/829x73header.png) no-repeat; }#profile_fullname { float:left; margin-left:50px; margin-top:30px; font-family:Tahoma, Geneva, sans-serif; font-size:19px; color:#FFF; }#profile_navigation { float:right; margin-top:25px; margin-right:50px; font-size:14px; font-family:Tahoma, Geneva, sans-serif; }.profilenavigation_link { float:left; } </style> <!-- TEMPLATE WRAPPER --> <div id="template_wrapper"> <!-- TEMPLATE HEADER --> <div id="template_header"> <!-- PROFILE FULLNAME --> <div id="profile_fullname"><--PROFILE_FULLNAME--></div> <!-- PROFILE NAVIGATION --> <div id="profile_navigation"><--PROFILE_NAVIGATION--></div> </div> The Result: (Source Code) the navigation links are being called before the template.. <a class="profilenavigation_link" href="http://#/p/sdchilderley">profile</a><a class="profilenavigation_link" href="http://#/p/sdchilderley/photos.html">photos</a><a class="profilenavigation_link" href="http://#/p/sdchilderley/videos.html">videos</a><a class="profilenavigation_link" href="http://#/p/sdchilderley/music.html">music</a><a class="profilenavigation_link" href="http://#/p/sdchilderley/friends.html">friends</a><a class="profilenavigation_link" href="http://#/p/sdchilderley/games.html">games</a> <!-- * * @Createdby: Shaun Childerley * @Version: 1.0.0 * @FileName: Icecold_blue * @Description: Default Profile Template * @Date: 10/01/2011 * --> <style type="text/css"> #template_wrapper { position:relative; margin: 0 auto; width:829px; margin-top:10px; }#template_header { float:left; width:829px; height:73px; background:url(http://#/profiles/templates/icecold_blue/global_images/829x73header.png) no-repeat; }#profile_fullname { float:left; margin-left:50px; margin-top:30px; font-family:Tahoma, Geneva, sans-serif; font-size:19px; color:#FFF; }#profile_navigation { float:right; margin-top:25px; margin-right:50px; font-size:14px; font-family:Tahoma, Geneva, sans-serif; }.profilenavigation_link { float:left; } </style> <!-- TEMPLATE WRAPPER --> <div id="template_wrapper"> <!-- TEMPLATE HEADER --> <div id="template_header"> <!-- PROFILE FULLNAME --> <div id="profile_fullname">Shaun Childerley</div> <!-- PROFILE NAVIGATION --> <div id="profile_navigation"></div> </div> P.S website URL has been removed. Edited January 11, 201115 yr by Shaun Childerley
January 11, 201115 yr I personally think this may do more use inside a function where you just have one return like return $profileTemplate; and one variable like $profileTemplate = str_replace(ect..); also a few parameters set on the function like function name($file,$tempSting,ect..) cause personally this is a very messy and drawn out way of doing a template system also could use a class which ever u would prefer Edited January 11, 201115 yr by webdesigner93
January 31, 201115 yr Please please can someone help me I have an existing site which which was made for me. The company that created it are very slow in terms of updating changes to the designer and static data. The problem im having is the site was created suing Smarty Template in php code I want to be able to edit the site myself as i have basic web design skills. but when I open any page it blank and I can see the page as it is on-line using dreamweaver. When I open the file in dreamweaver it say, Dynamically-related files cannot not be discovered because thee is no site definition for this document. and verouis other errors, I understand i need to create an environment locally? do you have any suggestion i have tried Wampsever does seem to work, I can only get one yellow light on. What is the best software for creating this type of environment? Will it display the page as it is on the web? will it support smarty templates or PHP Please you help will be so grateful. Thanks in advance for anyone that can help me. Why dont u make ur own topic? i cant stand people who thinks its ok to post for help within someone elses topic.
Create an account or sign in to comment