Jump to content

Smarty linking question nobody seems to know the answer to


jack2006

Recommended Posts

I've tried to have this answered on the smarty.net forum and digitalpoint, in the smarty forum i simply did not get an answer (cuz maybe it's to stupid to answer), the other onese did not solve the problem.

 

 

 

I have had a lancer write a script for me. He used smarty for it. Everything works fine but i don't know how to ad a link to another page of the site. He tells me that that functionality is not available and if i want it he will charge me for making it. (he has to create a module)

 

After digging around i have managed to figure out how to create a page in the system, I can even call it up within another page, but i don't know how to link to it so it displays independently. (It's an about us page and the link would be in the footer).

 

Here is what i have done so far:

 

I have created both a file called about.php and placed it where all my other php page files are. That file contains the following code

 

 

<?php
$obj['smarty']->assign('file_inc', 'about.tpl');
?>

I then created a file called about.tpl placed it in the templates folder and did my templating in that file.

 

I also included about.tpl in the database alongside the other pages listed in it.

 

Ok so now I would like to link to that file so it displays as domain.com/about.html (or php or anything really).

 

Here is my footer

 

 

 

<div id="footer">
<p>{$params.copyr} | <a href="mailto:{$params.email}">{$_lang.Contact_us}</a> |  <a href="mailto:bug@domain.com">Report Bugs</a></p>
    	<p><a href="">What is domain.com</a></p>

 

The part i don't know how to do is what to put in here:

 

 

<p><a href="????????">What is domain.com</a></p>

If i just place <a href="http://www.domain.com/about.php"> or any variation thereof (even include path to the file) and i click the link i am not taken to that page but left on my main page. (as if it was a 404 error or something).

 

I've been at this problem for a week and i'm about to go ape$%$% please someone help?

Link to comment
Share on other sites

You will not get a solution as the coder has used his own structure for your website. I'm guessing this is done using an MVC (model, view, controller) pattern. You may need to add a new class method or subclass for this page.

My advice would be to copy an existing page. What do the urls look like for other pages? They maybe parameter based.

Link to comment
Share on other sites

You will not get a solution as the coder has used his own structure for your website. I'm guessing this is done using an MVC (model, view, controller) pattern. You may need to add a new class method or subclass for this page.

My advice would be to copy an existing page. What do the urls look like for other pages? They maybe parameter based.

Not necessarily. Smarty systems aren't too different from one another, shockingly. It really doesn't matter what structure the coder used. Adding a variable is as simple as that.

Link to comment
Share on other sites

Not necessarily. Smarty systems aren't too different from one another, shockingly. It really doesn't matter what structure the coder used. Adding a variable is as simple as that.

 

That isn't the problem. Assigning a variable to a template is easy yes. He is asking what the url is to his new page for a link in his footer. Read the post. If he uses /about.php then the page does not display correctly.

Link to comment
Share on other sites

Ken2k7

 

So here what i have done as you suggested:

 

about.php

<?php
$obj['smarty']->assign('file_inc', 'about.tpl');
$obj['smarty']->assign('url', '/about.php');
?>

 

In tpl

<p><a href="{$url}">What is domain.com</a></p>

 

Unfortunately that did not work.

 

I've located the following code that talks about url's and all maybe that will help:

// Get the document
$document = $obj['tree']->get_item($obj['url']->link);


if (!$document)
{
	header("HTTP/1.1 404");
	$obj['smarty']->assign('file_inc', 'error404.tpl');
	$obj['smarty']->display('error404.tpl');
	exit;
}


if ( $document['isdir'] || $document['pid']!=0 )
{
if ( $document['pid']!=0 )
{
	$parent = $obj['tree']->get_item($document['pid']);
}
else 
{
	$parent = $document;
}

$parent['items'] = $obj['tree']->get_childrens($parent['id']);
$obj['smarty']->assign('document_parent', $parent);

}

//$path = $obj['tree']->get_path($document['id']);
$path = array();
$path2 = $path;
$path2[] = $document;

$document_not_found = 0;

if($document['public']) {
    foreach($handles as $h)
    {
    	if((int)$h['id'] == (int)$document['handle']) {
        	require($CFG['path']['process'] . $h['script']);
    	}
    }
}
else
{

header("Location: /");
exit();
}


// Checking is not whether to go to the first child element
if($document['is_gochild']) {
$childs = $obj['tree']->get_childrens($document['id']);
if (is_array($childs))
{
	header("Location: /" . $childs[0]['alias'] . ".html");
	exit;
}
}

// Smarty pass some of the variables

$obj['smarty']->assign('var', $VAR);
$obj['smarty']->assign('cfg', $CFG);
$obj['smarty']->assign('handles', $handles);
$obj['smarty']->assign('document', $document);
$obj['smarty']->assign('path', $path);
$obj['smarty']->assign('path2', $path2);
$obj['smarty']->assign('url', $obj['url']->url);

 

 

 

 

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{$params.title}</title>
<link rel="stylesheet" href="/images/css/style.css" type="text/css" />
<!--[if lt IE 8]><link rel="stylesheet" href="/images/css/ie.css" type="text/css" /><![endif]-->
<!--[if lt IE 7]><link rel="stylesheet" href="/images/css/ie6.css" type="text/css" /><![endif]-->
<script src="/javascripts/main.js" type="text/javascript"></script>

</head>
<body class="mainpage">
<div id="header">
<div class="inner">
	<h1 class="logo">{$params.sitename} <small>{$params.site_description}</small></h1>
	<div align="right">
	{foreach from=$_PL item=_lname key=_lalias}
		{if $smarty.session.lang!=$_lalias}<a href="?lang={$_lalias}">{$_lname}</a>{else}{$_lname}{/if}
	{/foreach}
	</div>
</div>
</div>
<div id="content">
  <form action="/work/enter" class="create-workt" id="new_room" method="post">  
  <input type="hidden" name="room" value="{$work_alias}" /> 
<fieldset>
	<div class="name">
	{if $smarty.get.pe}
		<center><b>{$_lang.Password_is_wrong}</b></center><br />
	{/if}
		<div class="bor">
			<input class="name enter-name" id="user_name" maxlength="20" name="username" size="20" type="text" value="{$_lang.Enter_your_name}" onfocus="MchName(this,true,'{$_lang.Enter_your_name}');" onblur="MchName(this,false,'{$_lang.Enter_your_name}');" style="color:#C0C2C5"/>
			{if $have_pass}
			<br />
			<input class="name enter-name" id="user_name" maxlength="20" name="password" size="20" type="text" value="{$_lang.Password}" onfocus="MchName(this,true,'{$_lang.Password}');" onblur="MchName(this,false,'{$_lang.Password}');" style="color:#C0C2C5"/>
			{/if}
		</div>
	</div>
	<div align="center"><input type="image" src="/images/design/forms/{$smarty.session.lang}/enter.png" class="btn enter-chat-logic"/></div>
</fieldset>

</form>

</div>
<div id="footer">
<p>{$params.copyr} | <a href="mailto:{$params.email}">{$_lang.Contact_us}</a> |  <a href="mailto:bug@domain.com">Report Bugs</a> | <a href="/pda/">Mobile Version</a></p>
</body>
</html>

Link to comment
Share on other sites

Normally it would but it just gives me a 404 error. In the database there is a table called handles where all the php files and their tpl files are listed I also added the about.php and tpl files there, it has an id # of 47

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.