Page 1 of 1

[Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 1:14 am
by alex7575
Hi everyone, i need your precious help :)

for my website, i needed to add a field in the MySQL Database, so i add the field "image_path" in the table "cms_module_news". This field contains the image's path link to the news posted on my website.

I also made a plugin called "get_imagepath" :
Execute($query);

if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['image_path'];
}
}


function smarty_cms_help_function_get_imagepath() {
?>
What does this do?
Displays the picture linked to your news.
How do I use it?
Just insert the tag into your page like: {get_imagepath fileid=""}
What parameters does it take?


fileid - the news id from the MySQL Database




Author: Alexandre Falaise afalaise@intechinfo.fr
Version: 1.0

Change History:
1.0 - Initial release

the plug'in works !!!!
I also made a news template and here is my problem
{if $entry->id}
id}'}" align="left" width="114" height="90"/>
{/if}
As you can see above, i used the "get_imagepath method"  but the '{$entry->id}' do NOT work in it.
Why??? we can not a "{...}" method in an another "{...}" ?? If not, how can i make this happens?

The {get_imagepath fileid='5'} works fine but not {get_imagepath fileid='{$entry->id}'}. WHY NOT?

i hope you can help me out.
thx, alex

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 2:36 am
by Ted
Did you try: {get_imagepath field=$entry->id}?

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 10:53 am
by alex7575
YEEEEEEEEEEEEEEEEEEEEEEEEEEEAH
thx dude :)
it works.... i worked until 4am last night so i didn't test that possibility :)

Last thing:
Is that possible in the admin panel (content > news > add news), to add a field in order to write into "image_path" which is in my database?
Because i currently writing into it by phpmyadmin and not from the admin panel... can i change the way i'm writing into it?

thank you for your help

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 11:03 am
by Ted
Modify modules/News/News.module.php.  Look for the addcontent and editcontent actions.  You should be able to add the fields there, and just modify the INSERT and UPDATE queries to have your new field as well.  It should be pretty easy.

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 12:09 pm
by alex7575
wishy wrote: Modify modules/News/News.module.php.  Look for the addcontent and editcontent actions.  You should be able to add the fields there, and just modify the INSERT and UPDATE queries to have your new field as well.  It should be pretty easy.
thank you for your quick answer :)
i can not find the addcontent and the editcontent :( i found some INSERT queries but i think it's during the installation when cmsms creates the table...
so if you can help me out... it could be great

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 12:39 pm
by alex7575
i found "addarticle" and "editarticle" :)
but what i did not find it's the way to add a field in the admin panel > add article



here are the modifications  i made, i didn't manage to add a field in the admin panel :(

line 848 case "addarticle":
$imagepath = '';
if (isset($params['imagepath']))
{
$imagepath = $params['imagepath'];
}

[...]


line 968 #Display template
$this->smarty->assign('imagepath', $this->Lang('imagepath'));
$this->smarty->assign('inputimagepath', $this->CreateInputText($id, 'imagepath', $imagepath, 30, 255));

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 1:02 pm
by alex7575
problem solved :)
if someone needs help about this... just ask

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 1:08 pm
by Ted
Ah, yes, addarticle and editarticle.  That's what I get for answering the forum at 6 am.  :)

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 1:40 pm
by alex7575
wishy wrote: Ah, yes, addarticle and editarticle.  That's what I get for answering the forum at 6 am.  :)
lol :)
but the editarticle does not work properly :( it does not update the database :'(
$query = 'UPDATE '.cms_db_prefix().'module_news SET news_title=?, news_data=?, summary=?, status=?, news_date=?, news_category_id=?, start_time=?, end_time=?, modified_date=? image_path=? WHERE news_id = ?';

if ($useexp == 1)
{
$db->Execute($query, array($title, $content, $summary, $status, $db->DBTimeStamp($postdate), $usedcategory, $db->DBTimeStamp($startdate), $db->DBTimeStamp($enddate), $db->DBTimeStamp(time()), $articleid,  $imagepath));
}
else
{
$db->Execute($query, array($title, $content, $summary, $status, $db->DBTimeStamp($postdate), $usedcategory, NULL, NULL, $db->DBTimeStamp(time()), $articleid, $imagepath));
}

Re: [Trouble] Template + Plugin SQL

Posted: Thu Dec 08, 2005 1:54 pm
by alex7575
works great :)
$db->Execute($query, array($title, $content, $summary, $status, $db->DBTimeStamp($postdate), $usedcategory, NULL, NULL, $db->DBTimeStamp(time()),  $imagepath, $articleid));
$imagepath before $articleid :)