PDA

View Full Version : چاپ نشدن کد در فایل های .tpl



eneahh
جمعه 02 آبان 1393, 10:18 صبح
سلام
من میخوام یک کدیو در قالب whmcs که با فرمت .tpl هست چاپ کنم
بعد از چاپ چنتا کاراکتر اضافه مثل <?;" میاد
مثلا من اینو میخوام چاپ کنم

<?php
echo "salam";
?>
این دستور هرجا چاپ بشه خروجیه slam میده اما در فایل .tpl خروجی اینه
";salam<?
لطفا راهنمایی کنید علت چیه

us1234
شنبه 03 آبان 1393, 14:20 عصر
whmcs از اسمارتی برای قالبش استفاده کرده .

داخل اسمارتی هم امکان استفاده از کدهای پی اچ پی نیست.

مثلا در کد پی اچ پی شما متغییر سلام را مقداری دهی کردید :

<?php $salam = 'salam'; ?>

برای نمایش در قالب باید به این صورت عمل کنید :

{$salam}

eneahh
شنبه 03 آبان 1393, 18:44 عصر
whmcs از اسمارتی برای قالبش استفاده کرده .

داخل اسمارتی هم امکان استفاده از کدهای پی اچ پی نیست.

مثلا در کد پی اچ پی شما متغییر سلام را مقداری دهی کردید :

<?php $salam = 'salam'; ?>

برای نمایش در قالب باید به این صورت عمل کنید :

{$salam}

ممنون از پاسختون دوست عزیز
مشکل حل نشد چون اسکریپت whmcs نیست و شبیح به اونه
فایل index.tpl اینه

<PCPIN:TPL name="main">
<form action="{FORMLINK}" method="post" onsubmit="doLogin(); return false;">
<table id="login_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_LOG_IN}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="login_username" value="{LOGIN_USERNAME}" type="text" size="16" maxlength="255" title="{LNG_USERNAME}" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="login_password" value="{LOGIN_PASSWORD}" type="password" size="16" maxlength="255" title="{LNG_PASSWORD}" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_LOG_IN}">{LNG_LOG_IN}</button>
<PCPIN:TPL name="guest_login" type="simplecondition" requiredvars="DISPLAY">
&nbsp;&nbsp;
<button type="button" title="{LNG_LOG_IN_AS_GUEST}" onclick="doGuestLogin()">{LNG_LOG_IN_AS_GUEST}</button>
</PCPIN:TPL>
</td>
</tr>
<PCPIN:TPL name="account_options" type="simplecondition" requiredvars="DISPLAY">
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<PCPIN:TPL name="account_options_register" type="simplecondition" requiredvars="DISPLAY">
<a href=":" title="{LNG_REGISTER}" onclick="showRegisterForm(); return false;">{LNG_REGISTER}</a>
<br />
</PCPIN:TPL>
<a href=":" title="{LNG_FORGOT_PASSWORD}" onclick="showResetPasswordForm(); return false;">{LNG_FORGOT_PASSWORD}</a>
</td>
</tr>
</PCPIN:TPL>
<PCPIN:TPL name="language_selection" type="simplecondition" requiredvars="DISPLAY">
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<b>{LNG_LANGUAGE}:</b>
<select id="language_selection" title="{LNG_LANGUAGES}" onchange="$('dummyform').language_id.value=this.value; $('dummyform').submit();">
<PCPIN:TPL name="language_selection_option">
<option value="{ID}" {SELECTED}>{LOCAL_NAME}</option>
</PCPIN:TPL>
</select>
</td>
</tr>
</PCPIN:TPL>
</table>
</form>
<PCPIN:TPL name="chat_summary" type="simplecondition" requiredvars="DISPLAY">
<div id="chat_summary" style="height:{HEIGHT}px;display:none;">
<iframe name="chat_summary_frame" src="./info.php" style="border:0;height:{HEIGHT}px;width:100%;" frameborder="0"></iframe>
</div>
</PCPIN:TPL>

<div id="pbl" style="position:absolute;font-size:smaller;">
<!--
PLEASE KEEP THIS UNCHANGED. THANK YOU.
-->
Powered by <a href="http://www.pcpin.com/" target="_blank" title="Powered by PCPIN Chat">PCPIN Chat</a>
</div>

<form action="{FORMLINK}" method="post" onsubmit="doRegister(); return false;">
<table id="register_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_REGISTRATION}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_username" value="" type="text" size="24" maxlength="{LOGIN_MAXLENGTH}" title="{LNG_USERNAME}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_EMAIL_ADDRESS}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_email" value="" type="text" size="24" maxlength="255" title="{LNG_EMAIL_ADDRESS}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_password1" value="" type="password" size="24" maxlength="255" title="{LNG_PASSWORD}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_CONFIRM_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_password2" value="" type="password" size="24" maxlength="255" title="{LNG_CONFIRM_PASSWORD}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_REGISTER}">{LNG_REGISTER}</button>
&nbsp;&nbsp;
<button type="button" title="{LNG_CANCEL}" onclick="showLoginForm()">{LNG_CANCEL}</button>
</td>
</tr>
</table>
</form>

<form action="{FORMLINK}" method="post" onsubmit="doResetPassword(); return false;">
<table id="reset_pw_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_PASSWORD_RESET}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="reset_pw_username" value="" type="text" size="24" maxlength="255" title="{LNG_USERNAME}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_EMAIL_ADDRESS}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="reset_pw_email" value="" type="text" size="24" maxlength="255" title="{LNG_EMAIL_ADDRESS}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_RESET_MY_PASSWORD}">{LNG_RESET_MY_PASSWORD}</button>
&nbsp;&nbsp;
<button type="button" title="{LNG_CANCEL}" onclick="showLoginForm()">{LNG_CANCEL}</button>
</td>
</tr>
</table>
</form>
</PCPIN:TPL>
لطفا ببینید اینجا چطوری میتونم یک کد پی اچ پی چاپ کنم؟

us1234
یک شنبه 04 آبان 1393, 19:47 عصر
باید دقیقا هدفتون را مشخص کنید .
منظور از چاپ کد پی اچ پی چیست ؟
میخواهد دقیقا چه متنی در کجا این قالب مشخص شود ؟

من یه مثال کاملتر از قبل میزنم .
ببنید اینجوری حل میشه :

در کد php :

$text = 'سلام';
$smarty->assign('mytext', $text);


و در قالب tpl :

{mytext}

eneahh
دوشنبه 05 آبان 1393, 10:44 صبح
باید دقیقا هدفتون را مشخص کنید .
منظور از چاپ کد پی اچ پی چیست ؟
میخواهد دقیقا چه متنی در کجا این قالب مشخص شود ؟

من یه مثال کاملتر از قبل میزنم .
ببنید اینجوری حل میشه :

در کد php :

$text = 'سلام';
$smarty->assign('mytext', $text);


و در قالب tpl :

{mytext}
تست کردم نشد خیلی راهارو تست کردم اما انجام نشد
من هم فایل .tpl میزارم و هم فایل .php شما نگاه کنید و داخلش یک نمونه بزنید و سلام رو چاپ کنید هرجای قالب .tpl چاپ بشه مهم نیست فقط چاپ بشه
تشکر
فایل php

<?php
/**
* This file is part of "PCPIN Chat 6".
*
* "PCPIN Chat 6" is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* "PCPIN Chat 6" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// Get available languages
if (!isset($language_id)) $language_id=0;

$languages=array();
if (!empty($session->_conf_all['allow_language_selection']) && !empty($session->_conf_all['login_language_selection'])) {
$languages=$l->getLanguages(false);
// Any language already selected
if (!empty($language_id)) {
foreach ($languages as $data) {
if ($language_id==$data['id'] || $language_id==$data['iso_name']) {
$preselect_language=$data['id'];
break;
}
}
}
if (empty($preselect_language)) {
// Get proposed by client languages
$preselect_language=0;
$accept_languages=!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])? explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) : array();
foreach ($accept_languages as $val) {
$val=strpos($val, ';')? substr($val, 0, strpos($val, ';')) : $val;
foreach ($languages as $data) {
if (strtolower(trim($val))==$data['iso_name']) {
$preselect_language=$data['id'];
break;
}
}
if (!empty($preselect_language)) {
break;
}
}
}
if (empty($preselect_language)) {
$preselect_language=$session->_conf_all['default_language'];
}
$l->setLanguage($preselect_language);
}

_pcpin_loadClass('pcpintpl'); $tpl=new PcpinTpl();
$tpl->setBasedir('./tpl');
$tpl->readTemplatesFromFile('./login.php');

$_body_onload[]='initLoginForm('.htmlspecialchars($session->_conf_all['login_length_min']).', '
.htmlspecialchars($session->_conf_all['login_length_max']).', '
.(!empty($admin_login)? 'true' : 'false')
.')';

// JS file for login
$_js_files[]='./js/login.js';

// JS language expressions
$_js_lng[]='username_empty';
$_js_lng[]='email_invalid';
$_js_lng[]='username_length_error';
$_js_lng[]='password_too_short';
$_js_lng[]='passwords_not_ident';

// Add global vars to template
foreach ($global_tpl_vars as $key=>$val) {
$tpl->addGlobalVar($key, htmlspecialchars($val));
}

// Add language expressions to template
foreach ($tpl->tpl_vars_plain as $var) {
if (0===strpos($var, 'LNG_')) {
$var=strtolower($var);
$tpl->addGlobalVar($var, htmlspecialchars($l->g(substr($var, 4))));
}
}

$tpl->addVar('main', 'login_maxlength', htmlspecialchars($session->_conf_all['login_length_max']));

$tpl->addVar('guest_login', 'display', empty($hide_account_options) && $session->_conf_all['allow_guests']);
$tpl->addVar('account_options', 'display', empty($hide_account_options));

$tpl->addVars('chat_summary', array('display'=>!empty($session->_conf_all['display_startup_summary']),
'height'=>htmlspecialchars($session->_conf_all['startup_summary_height']),
));

if (!empty($direct_login) && !empty($login) && !empty($password)) {
$tpl->addVars('main', array('login_username'=>htmlspecialchars($login),
'login_password'=>htmlspecialchars($password),
));
$_body_onload[]='doLogin()';
}

// Language selection
if (!empty($session->_conf_all['allow_language_selection']) && !empty($session->_conf_all['login_language_selection'])) {
$tpl->addVar('language_selection', 'display', true);
foreach ($languages as $data) {
$tpl->addVars('language_selection_option', array('id'=>htmlspecialchars($data['id']),
'local_name'=>htmlspecialchars($data['local_name']),
'selected'=>($data['id']==$l->id)? 'selected="selected"' : '',
));
$tpl->parseTemplate('language_selection_option', 'a');
}
}

// Display "Register" link
$tpl->addVar('account_options_register', 'display', $session->_conf_all['allow_user_registration']);
?>
فایل tpl

<PCPIN:TPL name="main">
<form action="{FORMLINK}" method="post" onsubmit="doLogin(); return false;">
<table id="login_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_LOG_IN}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="login_username" value="{LOGIN_USERNAME}" type="text" size="16" maxlength="255" title="{LNG_USERNAME}" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="login_password" value="{LOGIN_PASSWORD}" type="password" size="16" maxlength="255" title="{LNG_PASSWORD}" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_LOG_IN}">{LNG_LOG_IN}</button>
<PCPIN:TPL name="guest_login" type="simplecondition" requiredvars="DISPLAY">
&nbsp;&nbsp;
<button type="button" title="{LNG_LOG_IN_AS_GUEST}" onclick="doGuestLogin()">{LNG_LOG_IN_AS_GUEST}</button>
</PCPIN:TPL>
</td>
</tr>
<PCPIN:TPL name="account_options" type="simplecondition" requiredvars="DISPLAY">
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<PCPIN:TPL name="account_options_register" type="simplecondition" requiredvars="DISPLAY">
<a href=":" title="{LNG_REGISTER}" onclick="showRegisterForm(); return false;">{LNG_REGISTER}</a>
<br />
</PCPIN:TPL>
<a href=":" title="{LNG_FORGOT_PASSWORD}" onclick="showResetPasswordForm(); return false;">{LNG_FORGOT_PASSWORD}</a>
</td>
</tr>
</PCPIN:TPL>
<PCPIN:TPL name="language_selection" type="simplecondition" requiredvars="DISPLAY">
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<b>{LNG_LANGUAGE}:</b>
<select id="language_selection" title="{LNG_LANGUAGES}" onchange="$('dummyform').language_id.value=this.value; $('dummyform').submit();">
<PCPIN:TPL name="language_selection_option">
<option value="{ID}" {SELECTED}>{LOCAL_NAME}</option>
</PCPIN:TPL>
</select>
</td>
</tr>
</PCPIN:TPL>
</table>
</form>
<PCPIN:TPL name="chat_summary" type="simplecondition" requiredvars="DISPLAY">
<div id="chat_summary" style="height:{HEIGHT}px;display:none;">
<iframe name="chat_summary_frame" src="./info.php" style="border:0;height:{HEIGHT}px;width:100%;" frameborder="0"></iframe>
</div>
</PCPIN:TPL>

<div id="pbl" style="position:absolute;font-size:smaller;">
<!--
PLEASE KEEP THIS UNCHANGED. THANK YOU.
-->
Powered by <a href="http://www.pcpin.com/" target="_blank" title="Powered by PCPIN Chat">PCPIN Chat</a>
</div>

<form action="{FORMLINK}" method="post" onsubmit="doRegister(); return false;">
<table id="register_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_REGISTRATION}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_username" value="" type="text" size="24" maxlength="{LOGIN_MAXLENGTH}" title="{LNG_USERNAME}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_EMAIL_ADDRESS}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_email" value="" type="text" size="24" maxlength="255" title="{LNG_EMAIL_ADDRESS}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_password1" value="" type="password" size="24" maxlength="255" title="{LNG_PASSWORD}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_CONFIRM_PASSWORD}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="register_password2" value="" type="password" size="24" maxlength="255" title="{LNG_CONFIRM_PASSWORD}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_REGISTER}">{LNG_REGISTER}</button>
&nbsp;&nbsp;
<button type="button" title="{LNG_CANCEL}" onclick="showLoginForm()">{LNG_CANCEL}</button>
</td>
</tr>
</table>
</form>

<form action="{FORMLINK}" method="post" onsubmit="doResetPassword(); return false;">
<table id="reset_pw_table" class="tbl" border="0" cellspacing="1" cellpadding="0" style="position:absolute;display:none;">
<tr>
<td nowrap="nowrap" class="tbl_header_main" colspan="2">
{LNG_PASSWORD_RESET}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_USERNAME}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="reset_pw_username" value="" type="text" size="24" maxlength="255" title="{LNG_USERNAME}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row">
<b>{LNG_EMAIL_ADDRESS}:</b>
</td>
<td nowrap="nowrap" class="tbl_row">
<input id="reset_pw_email" value="" type="text" size="24" maxlength="255" title="{LNG_EMAIL_ADDRESS}" autocomplete="off" />
</td>
</tr>
<tr>
<td nowrap="nowrap" class="tbl_row" colspan="2" style="text-align:center">
<button type="submit" title="{LNG_RESET_MY_PASSWORD}">{LNG_RESET_MY_PASSWORD}</button>
&nbsp;&nbsp;
<button type="button" title="{LNG_CANCEL}" onclick="showLoginForm()">{LNG_CANCEL}</button>
</td>
</tr>
</table>
</form>
</PCPIN:TPL>

us1234
دوشنبه 05 آبان 1393, 11:34 صبح
یک خط مانده به <? در فایل پی اچ پی بزنید :


$salam = 'سلام';
$tpl->addVar('main', 'mysalam', $salam);


بعد از این خط <PCPIN:TPL name="main"> در فایل تی پی ال بزنید :


{MYSALAM}

eneahh
دوشنبه 05 آبان 1393, 13:53 عصر
یک خط مانده به <? در فایل پی اچ پی بزنید :


$salam = 'سلام';
$tpl->addVar('main', 'mysalam', $salam);


بعد از این خط <PCPIN:TPL name="main"> در فایل تی پی ال بزنید :


{MYSALAM}

سلام آقا جواب داد:تشویق: دستتون درد نکنه واقعا ممنونم:قلب:

eneahh
دوشنبه 12 آبان 1393, 22:32 عصر
دوستان یک سوال دیگه برام مطرح شده!
فرضا من این دستورو دارم و میخوام به صورت اسمارتی چاپ کنمش، چطوری باید این کارو کنم!

<?php

mysql_query('set names utf8');
$result3=mysqli_query($con,"SELECT field_value,name FROM pcpin_userdata inner join pcpin_userdata_field on pcpin_userdata_field.id=pcpin_userdata.field_id where pcpin_userdata.user_id=$id");

while($row3 = mysqli_fetch_array($result3))
{

echo'<tr>';
echo'<td style="text-align: left">'.$row3['name'].'</td>';
echo '<td> </td>';
echo'<td style="text-align: right" scope="col">'.$row3['field_value'].'</td>';
echo'</tr>';

}
?>
هدف این کد اینه که از دیتابیس نام کاربرو چاپ کنه
لطفا در فایل های php و .tpl که بالا دادم مثال بزنید تا متوجه بشم
نهایت تشکر

eneahh
دوشنبه 12 آبان 1393, 22:50 عصر
اینطوری جواب میده و از دیتابیس میخونه



<?php
mysql_query('set names utf8');
$result3=mysqli_query($con,"SELECT * FROM `jadval_name`");

while($row3 = mysqli_fetch_array($result3));
$content=$row3['name'];
$tpl->addVar('main', 'nickname', $content);

?>


اما وقتی بخوایم نام کاربر خاصی رو نشون بده چیکار کنم مثلا کاربری با اطلاعات کاربری یوزرنیم و پسورد وارد سایت میشه و میره تو قسمت پروفایلش تو این قسمت باید نام کاربری خودشو بزنه دیگه!
پس کد باید طوری نوشته بشه که نام کاربریو با توجه به آی دی نمایش بده یا به هر صورت دیگه ای که ممکنه!
همونطور که میبینید تو کد بالا اومدم از دو تیبل pcpin_userdata_field و pcpin_userdata استفاده شده که از تیبل pcpin_userdata_field نام کاربری رو میخونه و از تیبل pcpin_userdata آی دیه کاربرو میخونه
تو این کد پی اچ پی که استفاده میکدم مشکلی نداشتم اما میخوام بصورت اسمارتی درش بیارم


<?php
mysql_query('set names utf8');$result3=mysqli_query($con,"SELECT field_value,name FROM pcpin_userdata inner join pcpin_userdata_field on pcpin_userdata_field.id=pcpin_userdata.field_id where pcpin_userdata.user_id=$id");
while($row3 = mysqli_fetch_array($result3))
{
echo'<tr>';
echo'<td style="text-align: left">'.$row3['name'].'</td>';
echo '<td> </td>';
echo'<td style="text-align: right" scope="col">'.$row3['field_value'].'</td>';
echo'</tr>';
}
?>


لطفا راهنمایی کنید چطوری انجام بدم

Nabi
سه شنبه 13 آبان 1393, 16:36 عصر
اين قضيه هيچ ارتباطي به اسمارتي نداره و هيچ شباهتي هم به اون نداره، تنها شباهتش، نامگذاري پسوند tpl است!

نرم افزار خيلي خاص نوشته شده طوري که فقط نويسندش ميتونه ازش سر در بياره. طبعاً هم هيچ راهنمايي براش نيست و با خوندن کدهاي قبلي و آزمون خطا بايد جلو رفت که بسياز کار زمان بريه.
پيشنهاد من اينه از نرم افزارهايي استفاده کني که توسط فريم ورک هاي استاندارد و مطرح نوشته شده اند.

در هر صورت بعد از چند ساعت کار توي سورس به جواب رسيدم که عرض ميکنم.

توي قالب بين بلوک <PCPIN:TPL name="main"> جايي که ميخواي ليست کاربرا نمايش داده بشه اين کد رو بنويس:


<table border="1">
<PCPIN:TPL name="show_users">
<tr>
<td>{NAME}</td>
<td>{FIELD_VALUE}</td>
</tr>
</PCPIN:TPL>
</table>

سپس اين کد php رو استفاده کن:



mysql_query('set names utf8');$result3=mysqli_query($con,"SELECT field_value,name FROM pcpin_userdata inner join pcpin_userdata_field on pcpin_userdata_field.id=pcpin_userdata.field_id where pcpin_userdata.user_id=$id");
while($row3 = mysqli_fetch_array($result3))
{
$tpl->addVars('show_users', $row3);
$tpl->parseTemplate('show_users', 'a');
}



موفق باشي