[Trouble] Template + Plugin SQL

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
alex7575

[Trouble] Template + Plugin SQL

Post 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
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: [Trouble] Template + Plugin SQL

Post by Ted »

Did you try: {get_imagepath field=$entry->id}?
alex7575

Re: [Trouble] Template + Plugin SQL

Post 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
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: [Trouble] Template + Plugin SQL

Post 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.
alex7575

Re: [Trouble] Template + Plugin SQL

Post 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
alex7575

Re: [Trouble] Template + Plugin SQL

Post 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));
alex7575

Re: [Trouble] Template + Plugin SQL

Post by alex7575 »

problem solved :)
if someone needs help about this... just ask
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: [Trouble] Template + Plugin SQL

Post by Ted »

Ah, yes, addarticle and editarticle.  That's what I get for answering the forum at 6 am.  :)
alex7575

Re: [Trouble] Template + Plugin SQL

Post 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));
}
alex7575

Re: [Trouble] Template + Plugin SQL

Post 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 :)
Post Reply

Return to “Developers Discussion”