Can’t figure out how to use and place images...

6 posts by 2 authors in: Forums > CMS Builder
Last Post: May 7, 2008   (RSS)

By einslistir - May 6, 2008 - edited: May 6, 2008

Hello, CMS Builder friends!

I feel like I am in a kind of big trouble, because there are lots of things, I can’t figure out with this outstanding CMS script. I am almost giving up hope, but now I have to take benefit from your very good support.

My biggest problem is images, especially on the frontpage, but also other places. I can’t figure out, how to place them, e.g. when using the align command, pushing the image to the left or right side.

Take a look at the mid section on the frontpage here (http://televarp.fo.space2u.com/index.php) how it looks on the actual homepage, and here (http://televarp.fo.space2u.com/index.htm) how I would like it to look like.

My biggest confusion is placing commands like <?php foreach ?> and <?php endforeach ?>, and also I can’t figure out why there is only one thumbnail on the “real” frontpage. All the news stories have big images AND thumbs.

Also I would like to know, how I could swap the images, so the first one is aligning to the left and the next one to the right. Also the <hr> command between the news items gives me trouble, because it doesn’t always go beyond the image, but that is another matter of not that big importance.

Well, a whole lot of confusion, but hopefully some of you understand, what I mean, and how to help me out...!

Re: [einslistir] Can’t figure out how to use and place images...

By Dave - May 6, 2008

hi einslistir, we're here to help! :)

You can pretty much have it display any way you want. What do you want displayed on the front page?

Here's some custom code you can use to rotate back and forth between left and right for the images:

align="<?php echo (@$row++ % 2) ? "left" : "right"; ?>"

Not that that assumes you'll only have one image per row.

Hope that helps. Let me know how else you'd like it different and we can help you get it sorted out!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Can’t figure out how to use and place images...

By einslistir - May 7, 2008

I still don’t get the images (thumbs) shown for more than one story, the one in top. I want to have one thumbnail for each story. What am I doing wrong? I would wish, there was a help file just about how it is possible to place images...

Also I don’t want a linebreak to be after the date. I want the date and the summary to be on the same line. It seemes to me, that each <?php echo ... ?> command results in a linebreak, that disturbs how I would have it to look.

Below is my code on the page, and the actual result of the code can be seen here: http://televarp.fo.space2u.com/index.php

<!-- STEP1: Load Record List (Paste this above other steps) -->
<?php
require_once "/home/d26454/public_html/lib/viewer_functions.php";
$tidindiOptions = array(); // NOTE: see online documentation for more details on these options
$tidindiOptions['tableName'] = 'tidindi'; // (REQUIRED) MySQL tablename to list record from. Example: 'article';
$tidindiOptions['titleField'] = 'title'; // (optional) MySQL fieldname used in viewer url for search engines. Example: 'title' would display: viewer.php/article_title_here-123
$tidindiOptions['viewerUrl'] = 'tidindiPage.php'; // (optional) URL of viewer page. Example: '/articles/view.php';
$tidindiOptions['perPage'] = ''; // (optional) The number of records to display per page. Example: '5'; Defaults to 10.
$tidindiOptions['orderBy'] = 'featured DESC, date DESC, title'; // (optional) Fieldnames to sort by. Example: 'field1, field2 DESC, field3';
$tidindiOptions['pageNum'] = ''; // (optional) Page number of results to display. Example: '1'; Defaults to ?page=# value, or 1 if undefined
$tidindiOptions['where'] = ''; // (ADVANCED) Additional MySQL WHERE conditions. Example: 'fieldname = "value"'
$tidindiOptions['useSeoUrls'] = ''; // (ADVANCED) Set this to '1' for search engine friendly urls: view.php/123 instead of view.php?123 (not supported on all web servers)
list($tidindiRecordList, $tidindiListDetails) = getListRows($tidindiOptions);
?>
<!-- /STEP1: Load Record List -->

<!-- STEP1: Load Record (Paste this above other step) -->
<?php
require_once "/home/d26454/public_html/lib/viewer_functions.php";
$tidindiOptions = array(); // NOTE: see online documentation for more details on these options
$tidindiOptions['tableName'] = 'tidindi'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$tidindiOptions['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$tidindiOptions['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$tidindiOptions['orderBy'] = 'featured DESC, date DESC, title'; // (optional) Fieldnames to sort by. Example: 'field1, field2 DESC, field3';
$tidindiRecord = getRecord($tidindiOptions);
?>
<!-- /STEP1: Load Record -->

<!-- STEP2: Display Record List (Paste this where you want your records to be listed) -->
<!-- STEP3: Display Uploads from 'uploads' (Paste this where you want your uploads displayed) -->
<!-- Upload Program Fields : num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath -->
<!-- Upload Image Fields : isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight -->
<!-- Upload Info Fields : info1, info2, info3, info4, info5 -->
<?php if ($tidindiRecord): ?>
<?php foreach (getUploads($tidindiOptions['tableName'], 'uploads', $tidindiRecord['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" align="<?php echo (@$row++ % 2) ? "left" : "right"; ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<!-- STEP3: /Display Uploads from 'uploads' --><?php foreach ($tidindiRecordList as $tidindiRecord): ?>
<a href="<?php echo $tidindiRecord['_link'] ?>"><h3><?php echo $tidindiRecord['title'] ?></h3></a>
<?php echo $tidindiRecord['summary'] ?>
<?php endforeach ?>
<!-- /STEP2: Display Record List -->

Re: [einslistir] Can’t figure out how to use and place images...

By Dave - May 7, 2008

I see. You want a record list, so keep the first part "Step1: Load Record List".

You don't want to load an individual record on this page, so erase the part called "STEP1: Load Record (Paste ...)".

Next, find this line and press enter a few times after it:
<?php foreach ($tidindiRecordList as $tidindiRecord): ?>

The move "STEP3: Display Uploads" inside of that.

Hope that makes sense! Feel free to attach the file if you need more help. Also, if you're not too far along you may consider upgrading. The latest version generates list page code including images for you and is a little simpler.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [einslistir] Can’t figure out how to use and place images...

By Dave - May 7, 2008

The trick is to do the PHP part last. If you do the HTML and PHP at the same time it's confusing.

All of the spacing issues are to do with HTML, not CMS Builder. CMS Builder can output content exactly like any you could custom code. The wysiwyg sometimes adds paragraph tags though.

Start with an HTML mockup. If you want to base it off your index.htm then use that same HTML. Or if you want to switch to a table based design then do a mockup first so you can figure out any spacing or design issues in HTML first.

One easy way to do that is just save a copy of the page output by index.php and adjust to html to see what the problem is. That will help you find the problem fast.

One thing I did notice is an extra break here. Try removing that:

<!-- STEP3: /Display Uploads from 'uploads' -->
<br/> <?php echo $tidindiRecord['summary'] ?>


On the upgrade, it generates different code but gives you a menu to choose what you want on the generated pages. All the old code will work still, though. Upgrading is almost always seamless, but it's a good idea to always make a backup first.

Hope that helps, let me know how it goes!
Dave Edis - Senior Developer
interactivetools.com