Support Forums

Modifying a Listing

This is a discussion on Modifying a Listing within the Technical Support forums, part of the Technical Support Forums category; Can anyone PLEASE help me with this ..... WHEN EDITING A LISTING, the edit listing function is in the file ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 09-22-2009, 06:32 PM   #1
Senior Member
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 219
Rep Power: 10
MrGForce is on a distinguished road
Default Modifying a Listing

Can anyone PLEASE help me with this .....

WHEN EDITING A LISTING, the edit listing function is in the file .... includes/classes/kernel/Listings.php

The Edit Listing Function code is indicated below. I've used the {debug} command to see what variables are available during the edit procedure. One of the variables available to me because of activating the SEO module from TemplateCodes is a $modified variable (field). Because of this, as you are proceeding to edit a listing, this $modified variable picks up the current date and time and places it in a modified field in the listing structure. As someone edits their listing, I would like the EDIT function to replace the "dateadded" field, indicated below in red, with this "$modified" variable as the listing is edited.

Does anyone know how to do this? The GetSQLValueString for $dateadded" is highlighted in red below.

Thanks.


.

/**
* Edit Listing
*

$sSQL=sprintf("UPDATE ".PREFIX."listings SET owner=%s,title=%s,section=%s,shortDescription=%s,d escription=%s,featured=%s,price=%s,display=%s,date added=%s,expiration=%s,url=%s,pBold=%s,pHighlighte d=%s WHERE id=%s",
GetSQLValueString($data['owner'],"int"),
GetSQLValueString(htmlspecialchars($data['title']),"text"),
GetSQLValueString($data['section'], "int"),
GetSQLValueString(htmlspecialchars($data['shortDescription']),"text"),
GetSQLValueString(htmlspecialchars($data['description']),"text"),
GetSQLValueString($data['featured'], "text"),
GetSQLValueString($data['price'], "double"),
GetSQLValueString($data['display'], "text"),

GetSQLValueString($data['dateadded'], "text"),

GetSQLValueString($data['expiration'], "text"),
GetSQLValueString($data['url'], "text"),
GetSQLValueString($data['bold'], "text"),
GetSQLValueString($data['highlighted'], "text"),
GetSQLValueString($data['id'], "int"))



.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline  
Old 09-23-2009, 08:20 AM   #2
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,954
Rep Power: 58
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

You would first need to "get" your special $modify field as well as "assign" it to the template. Then you would need to "post" that field variable to the function as well as add the variable to the update query.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline  
Old 09-23-2009, 08:54 AM   #3
curmudgeon
 
Join Date: Mar 2006
Posts: 5,248
Rep Power: 128
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by Mike-N-Tosh
You would first need to "get" your special $modify field as well as "assign" it to the template. Then you would need to "post" that field variable to the function as well as add the variable to the update query.
Why?

There is nothing here that the user needs to interact with so you dont need to get the templates involved at all, just alter the update to update the dateadded.

What I would do is just above the query define a new variable and assign it the current date and time, something like this......


$modifyadded = date("Y-m-d H:i:s");


and then alter the query line to this....


GetSQLValueString($modifyadded, "text"),
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 09-23-2009, 09:15 AM   #4
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,723
Rep Power: 66
seymourjames is a jewel in the rough
Default

I also believe the modified date variable is available from the templatecodes system framework so you could just put it in directly.

Always back up your database too.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds
seymourjames is offline  
Old 09-23-2009, 08:05 PM   #5
Senior Member
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 219
Rep Power: 10
MrGForce is on a distinguished road
Default

Thanks guys for your response.

Larry, I tried your idea, and when I used the {debug} command, the modifyadded variable did not show up. I put the variable just above the $sSQL statement and it didn't show up in the debug screen. But while I was looking for that variable, I did see the $modified variable which had today's date and time as it's text. So I replaced the $modifyadded variable in the query line with the $modified variable and that didn't work either. The $dateadded field doesn't change.

And David, I'm not quite sure what you mean by .... "variable is available from the templatecodes system framework so you could just put it in directly". Not sure where or how I would do this.

And Mike .... oh my. I wish I knew how to do what you mentioned, but I'm really new to sql.

Any other thoughts?

Thanks again guys.



.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline  
Old 09-23-2009, 09:50 PM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,248
Rep Power: 128
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by MrGForce
Thanks guys for your response.

Larry, I tried your idea, and when I used the {debug} command, the modifyadded variable did not show up.
Thats to be expected, debug ONLY shows variables that have been ASSIGNED to the template.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 09-24-2009, 06:33 AM   #7
Senior Member
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 219
Rep Power: 10
MrGForce is on a distinguished road
Default

Larry, even though the new variable $modifyadded doesn't show up using {debug}, that still doesn't tell me why the $dateadded field can't be replaced by another variable, such as the $modified variable, which does show in the smarty info, when the listing is written back to the database. The $modified variable is there in the smarty info, with the current date and time indicated, which is written back to the listing when you click the save button, but when you change the line below to use that variables text for the $dateadded field, the save function simply ignores it as it's writing the info back to the database.

Your suggestion ..... GetSQLValueString($modifyadded, "text"),

I changed it to .... GetSQLValueString($modified, "text"),


I checked out this prior post which was concerning 68C ver3. The date was being changed back then when modifying a listing, but the files have doing that have all changed since then. At that time, this function should have been made a yes or no setting in the admin instead of removing it, as there are some that want it, like myself, and others who don't. The thread url for that other posting is ....

http://www.68classifieds.com/forums/...ed-change.html


.
.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template

Last edited by MrGForce; 09-24-2009 at 06:43 AM.
MrGForce is offline  
Old 09-24-2009, 08:19 AM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,248
Rep Power: 128
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by MrGForce
Larry, even though the new variable $modifyadded doesn't show up using {debug}, that still doesn't tell me why the $dateadded field can't be replaced by another variable, such as the $modified variable, which does show in the smarty info, when the listing is written back to the database. The $modified variable is there in the smarty info, with the current date and time indicated, which is written back to the listing when you click the save button, but when you change the line below to use that variables text for the $dateadded field, the save function simply ignores it as it's writing the info back to the database.

Your suggestion ..... GetSQLValueString($modifyadded, "text"),

I changed it to .... GetSQLValueString($modified, "text"),


I checked out this prior post which was concerning 68C ver3. The date was being changed back then when modifying a listing, but the files have doing that have all changed since then. At that time, this function should have been made a yes or no setting in the admin instead of removing it, as there are some that want it, like myself, and others who don't. The thread url for that other posting is ....

http://www.68classifieds.com/forums/...ed-change.html


.
.
This is why I dont like to get involved in these threads. Hacking up your code when you dont understand the basics of how smarty and php interact is just asking for trouble. Cut and pasting your way through a site is NOT the way to modify your site. When you make a change YOU should understand the who,what, why and where of it.

You said my suggestion didnt work but you did not show me exactly what you did. Did you add the line above the sql line to define the new variable $modifyadded? Have you tried echoing the variable after the line where it was created to see if its there and of the same format as the database field?

You keep bringing up variables shown by debug and how they exist and other fields are getting modified but you seem to not understand the relationship between the templates and the back end scripts. Technically speaking the front end templates dont have to have or pass any variables to the underlying script for it to do anything.

The recommendation I made above assumes that the edit listing function is being run and then just creates its own time/date variable based on the current system time to update the record. It doesnt need input from the templates or the user.

As for a toggle to allow the date added date to change, bring that up to 68C. Personally dont see the value in it and most 68C clients dont either because it isnt brought up that often. The date an ad was added is the date it was added. Changing the added date when an ad is modified serves what purpose? So it shows at the top of the list again in sorts? If I post an ad on a site and I know thats how it works, guess what, I will update my ad every day to keep it on top. Likely most other users will to so then whats accomplished?
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 09-24-2009, 08:47 AM   #9
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,723
Rep Power: 66
seymourjames is a jewel in the rough
Default

Have you checked the variables are the same format?
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds
seymourjames is offline  
Old 09-24-2009, 08:50 AM   #10
curmudgeon
 
Join Date: Mar 2006
Posts: 5,248
Rep Power: 128
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by seymourjames
Have you checked the variables are the same format?
I asked that
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra Value Select Lists Resetting When Modifying A Listing bgordon Technical Support 1 02-14-2009 06:00 PM
Users Modifying and Ad loudmouthclassifieds Technical Support 3 02-10-2009 11:00 AM
modifying an ad... wundermummy Technical Support 3 09-10-2008 06:37 PM


All times are GMT -4. The time now is 02:38 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0