Lightbox/Slimbox and Product view counter in Shop Module

Get help with installation and running official modules for phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
achilehero
Posts: 69
Joined: Sun 4. Jan 2009, 13:30

Lightbox/Slimbox and Product view counter in Shop Module

Post by achilehero »

Hi everybody!

Can someone help me, please, with some hints?
I would like to have several pictures in the product details page (the buyer needs to see more details of a product) shown as thumbnails and have them opened with Lightbox/Slimbox for larger detail by clicking on them. I tried looking in frontend.render.php of the shop module, but it seems that my php skills are not enough for me to figure this out.

I would also like to display how many times each product has been accessed.

I would appreciate any help/hint on these two subjects. Thank you very much, indeed!
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by juergen »

my advice:

do not explore new wheels ->

in frontendrender part of the shop place the function {SHOW_CONTENT_SHOP:....} and you can get anything done inside the shop.

you only copy the function which does this, rename it and change the replacement...

I did this in an other module ...works like a charme.
achilehero
Posts: 69
Joined: Sun 4. Jan 2009, 13:30

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by achilehero »

Thanks a lot for the tip. But could you be a litlle bit more specific, maybe even an example of what you did? I am not sure I understood exactly what you said. I would appreciate it.
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by juergen »

ok, here we go:

lets call the show_content annother name :

Code: Select all

/*
 * {SHOW_CONTENT} 
 * thanks to Jens Zetterström who has initiated this in 2005
 * Shows the content of the article content part with the specified id.
 * use it {SHOW_CONTENT:MODE,id[,id[,...]]}
 * where MODE is what should returned
 * and id is the corresponding ID
 * MODE options:
 *   CP   - list of Content Parts | id = id of the content part, one or more possible, comma seperated.
 *   CPA  - ascending list of Content Parts but based on selected article  | id = id of article, comma seperated
 *   CPAD - same as CPA, but descending
 *   AS   - list of Article Summaries | id = id of articles, comma separated
 *   CAS  - list of Article Summaries | id = id of structure level, comma separated
 */
function Mshow($param='') {

	global $template_default;
	global $db;
	global $content;
	global $block;
	global $phpwcms;
	global $aktion;
	
	$topcount = 999999;
	$template = '';
	
	if($cp = explode(',', $param)) {
		$mode	= strtoupper(trim($cp[0]));
		if(substr($mode, 0, 2) == 'AS') {
			$mode = explode('|', $cp[0]);
			if(isset($mode[1])) {
				$mode[1] = trim($mode[1]);
				if(is_numeric($mode[1])) {
					$topcount = intval($mode[1]);
				} elseif(empty($mode[2]) && strlen($mode[1]) > 4 && ($mode[1] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[1]))) {
					$template = $mode[1];
				}
			}
			if(isset($mode[2])) {
				$mode[2] = trim($mode[2]);
				if(is_numeric($mode[2])) {
					$topcount = intval($mode[2]);
				} elseif(strlen($mode[2]) > 4 && ($mode[2] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[2]))) {
					$template = $mode[2];
				}
			}
			$mode = strtoupper(trim($mode[0]));
			if(isset($cp[1])) { // now check if 
				$cp[1] = trim($cp[1]);
				if(!is_numeric($cp[1])) {
					switch($cp[1]) {
						case 'new':		$cp = array('new'		=> 1);	break;
						case 'random':	$cp = array('random'	=> 1);	break;
						case 'related':	if(isset($cp[2])) {
											unset($cp[0], $cp[1]);
											$related = array();
											foreach($cp as $value) {
												$related[] = "article_keyword LIKE '%".aporeplace(strtoupper(trim($value)))."%'";
											}
											$cp = array('related' => 1); break;
										}
					
						default:		$cp = array('new'		=> 1);
					}
				}
			}
		}
		unset($cp[0]);
		foreach($cp as $key => $value) {
			$value	= intval($value);
			if(!$value) {
				unset($cp[$key]);
			} else {
				$cp[$key] = $value;
			}
		}
		if(!is_array($cp) || !count($cp)) {
			return '';
		}
	} else {
		// oh no ID given, end function
		return '';
	}
	
	$CNT_TMP = '';
	
	if(substr($mode, 0, 2) == 'AS') {
	
		if(substr($mode, -1) == 'P') {
			$mode = substr($mode, 0, -1);
			$priorize = 'article_priorize DESC, ';
		} else {
			$priorize = '';
		}
		
		switch($mode) {
							
			case 'ASL':		$sort = $priorize.'article_begin ASC';		break; // sorted by livedate ascending
			case 'ASLD':	$sort = $priorize.'article_begin DESC';		break; // sorted by livedate descending
			case 'ASK':		$sort = $priorize.'article_end ASC';		break; // sorted by killdate ascending
			case 'ASKD':	$sort = $priorize.'article_end DESC';		break; // sorted by killdate descending
			case 'ASC':		$sort = $priorize.'article_tstamp ASC';		break; // sorted by change date ascending
			case 'ASCD':	$sort = $priorize.'article_tspamp DESC';	break; // sorted by change date descending
			case 'ASR':		$sort = 'RAND()';							break; // random sort
			default:		$sort = '';

		}

		$CNT_TMP = list_articles_summary( get_article_data( $cp, $topcount, $sort ) , $topcount, $template);


	} elseif($mode == 'CP' || $mode == 'CPA' || $mode == 'CPAD') {
	
		$sort = ($mode=='CPAD') ? ' DESC' : ''; //means ASCENDING
	
		foreach($cp as $value) {
		
			if($mode == 'CP') { 
				// content part listing
				$sql  = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent ";
				$sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON ";
				$sql .= DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid ";
				$sql .= "WHERE acontent_id = " . $value . " AND acontent_visible = 1 ";
				
				if( !FEUSER_LOGIN_STATUS ) {
					$sql .= 'AND acontent_granted=0 ';
				}
				
				$sql .= "AND acontent_trash = 0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 AND ";
				$sql .= DB_PREPEND."phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() ";
				$sql .= "LIMIT 1";
				
			} else {
				// content parts based on article ID				
				$sql  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent ";
				$sql .= "WHERE acontent_aid=". $value." AND acontent_visible=1 AND acontent_trash=0 ";
				
				if( !FEUSER_LOGIN_STATUS ) {
					$sql .= 'AND acontent_granted=0 ';
				}
				
				$sql .= "ORDER BY acontent_sorting".$sort.", acontent_id";
				
			}
		
			if($cresult = mysql_query($sql, $db)) {
				while($crow = mysql_fetch_assoc($cresult))	{
				
					if($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]])) {
						continue;
					}
				
					if($crow["acontent_type"] == 24) {
						// first retrieve alias ID information and settings
						$crow = getContentPartAlias($crow);
					}
				
					$space = getContentPartSpacer($crow["acontent_before"], $crow["acontent_after"]);
					
					// Space before
					$CNT_TMP .= $space['before'];
					
					// set frontend edit link
					$CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
											
					// include content part code section
					if($crow["acontent_type"] != 30) {
					
						include(PHPWCMS_ROOT.'/include/inc_front/content/cnt' . $crow["acontent_type"] . '.article.inc.php');
					
					} elseif($crow["acontent_type"] == 30 && file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) {
				
						$CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']);
				
						// now try to include module content part code
						include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php');
				
					}
			
					//check if top link should be shown
					$CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
					
					//Maybe content part ID should b used inside templates or for something different
					$CNT_TMP  = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP );
					
					// trigger content part functions
					$CNT_TMP = trigger_cp($CNT_TMP, $crow);
			
					// Space after
					$CNT_TMP .= $space['after'];
					
				}
				mysql_free_result($cresult);
			}
		}
	}
	
	if(empty($phpwcms["allow_cntPHP_rt"])) {
		$CNT_TMP = remove_unsecure_rptags($CNT_TMP);
	}
	return $CNT_TMP;
}

so if you are in the render section of the shop ( reminds me to be in frontend.render.php ) include or place this function inside. If your shop / your article , whatelse is rendered replace the {MSHOW} with the return value of this function.

That's all

Jürgen
achilehero
Posts: 69
Joined: Sun 4. Jan 2009, 13:30

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by achilehero »

One more thing, before I analyze the code more in depth... Is this solution for the counter part, of for the slimbox/lightbox part?
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by juergen »

hmm .. for anything which is inside wcms (anything that can be done by contentparts).

That means that the hidden counter ist NOT, but that'll be easy to be done via sql fe.
achilehero
Posts: 69
Joined: Sun 4. Jan 2009, 13:30

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by achilehero »

OK. So the problem with Slimbox in the shop module is as follows:

If I use the shop, for each product I can add pictures. So ... I don't have to use any other contentpart. I just want to be able to display these pictures (that appear in the product detail view), slightly larger with Slimbox. I don't want to use any other CPs because the website will be done for a client and ... I don't want to teach him a lot of features that would be hard to understand/use for him.

You can look at http://www.fastaris.ro and go to Produse/Diverse to see what I mean about a product.


Thanks!
Last edited by achilehero on Tue 21. Jul 2009, 10:27, edited 1 time in total.
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by juergen »

Oha .. I know these products ... saw a cat excavator ..

for more pics the shop has to be changed, when being inside the shop module... javascript has to be adapted in backend, the lightbox frontend is only 2 changes.

Takes some hours, ask Oliver, ask marcus,me, yourself, whatever you want. ;)
achilehero
Posts: 69
Joined: Sun 4. Jan 2009, 13:30

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by achilehero »

Yes, I know! Thanks a lot, Jürgen!

I looked only into changing the frontend, but I'll take a look at the backend, too. Maybe I'll contact you if I cannot make it, of course, if it's OK with you. I wouldn't want to bother Oliver with those problems.


Thanks a lot again!

Chris
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: Lightbox/Slimbox and Product view counter in Shop Module

Post by juergen »

I don't think Oliver will be bothered, my only fear whether a new release is comming *g*

If you dump Vars each step, well knowing that olis cosde always works var-name-> db-field Name.
I did try the hell to get multiple pics from filecenter to content with this java script, moving up, down, selecting and so on... :cry: :lol:
Post Reply