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)

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: [Dave] Can’t figure out how to use and place images...

By einslistir - May 7, 2008

Thanks for the quick and very helpful reply!

Now I have tried with some tables to get the most out of the layout, which seemes not to be in my hands in the same way, I am used to. Guess, it is some of the php code, that confuses me...

Still I haven’t found out, why the code seemes to do linebreakes everywhere. As I told in the message before, it is not possible to have e.g. date and summary at the same line, without getting some linebreaks, that I don’t want to have.

Also the text (summary) should start at the same height as the picture, but there always seemes to be linebreaks, that pushes the text a little bit down. What is the solution to that?

Sounds great with the new upgrade, that let me handle e.g. images a little bit easier. As you see, it is a little problem to me. If I upgrade, will there be any need for a backup first, or will the replacements with the upgrade just do things a little easier to handle?

The index.php file is attached.
Attachments:

index_003.php 17K

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