Getting a message about Quirks mode? (Not an error?)

Based on advice from fackrellj on my previous “Tables” post, I’ve been playing around with the values.phtml to try and tell Omeka S: If there are more than 2 values for a property, look and see if both "type=numeric:integer" and "type=text" are present. If so, do this...

So this is the code that I have right now:

<?php
$options = [];
if ($this->siteSetting('exclude_resources_not_in_site')) {
    $options['siteId'] = $this->currentSite()->id();
}


$propertyValues = $this->$property['values'];

interface amtItem {
	public $lineAmt;
	public $lineItem;
	}
class ListLine implements amtItem {
	public function __construct($lineAmt, $lineItem) {
		$this->lineAmt = $lineAmt;
		$this->lineItem = $lineItem;
	}
	public function __destruct() {
		echo '<tr class="listItem">
		<td id="ItemAmt">' . $lineAmt . '</td>
		<td id="itemLine">' . $lineItem . '</td>
		</tr>';
	}
}

if ($propertyValues[$i]->count() > 1) {
	$addTable = '<table></table>';
	echo $addTable;
	foreach($propertyValues[]->children() as $value) {
		return $value->gettype();
		if(gettype($value) == "numeric" or "string"){
			switch ($value) {
				case $value->is_numeric() == 1:
					define($lineAmt, $value);
					$addTable.appendChild($lineAmt);
					break;
				case $value->is_string() == 1:
					define($lineItem, $value);
					$addTable.appendChild($lineItem);
					break;
				default:
					break;
			}
		}
	}
	do {
		$i++;
		if ($i == 0) continue;
		return $listItem = [$lineAmt, $lineItem];
	} while ($propertyValue[$i]==$lineAmt && $propertyValue[$i+1]==$lineItem);
	$listItem = new ListLine();
}

echo $resource->displayValues($options);
?>

I’m not getting any errors, but I do get a mostly white screen and a message about “Quirks mode”? Since it not technically an error, I’m not getting a message about it in my Logs. So what do I need to fix?

Hi @megtrip3 ,

I’m not sure exactly why your browser is going into quirks mode, but you’ve got a lot of things going on in that code snippet that are not valid PHP or at least not very typical.

I can take a few minutes today to write it and how I might do it to accomplish what you want.

I am wondering if you really want to create a list property and separate the label and value like you’re doing. I might suggest putting them in the same field (e.g. Triplet:3, Cats:2, or Triplet|3, Cats|2, etc.). This would easily let you detect the presence of a multivalue field by checking for the delimiting character’s presence. You could then split the filed value and this would ensure that the label and value always match up. There could be some implications if you did it this way for searching, facets, or linked metadata values, and you would have to decide if it’s worth the tradeoff.

I’d be interested in seeing how both ways worked. I’m trying to keep searchability (which is why I also posted about adding to the NumericDataType module), but it’s always nice to know how to do something multiple ways.

@megtrip3 , I think this is a little cleaner way to do what you’re trying to do above. I think you could simplify this a little if you’re guaranteed to always have an integer followed by a literal string. If you don’t have that, then you might need some additional checking.

Keep in mind that this is just for displaying the one list field and you would also probably need to add some logic to display the other values for the item. You could even make this more dynamic to handle multiple list fields without updating the template. However, I don’t think I can spend any more time working on this problem right now.

<?php
$items = [];
$values = $resource->value('dhterm:items', ['all' => true]);
foreach ($values as $key => $value){
    if($value->type() == 'numeric:integer'){
        $items[] = [
            'value' => $value->asHtml(),
            'label' => ($values[$key+1]->type() == 'literal') ? $values[$key+1]->asHtml() : '',
        ];
    }
}
?>

<table>
    <thead>

    </thead>
    <tbody>
    <tr>
        <td>Items</td>
        <td>
            <table>
                <thead></thead>
                <tbody>
                <?php foreach ($items as $item): ?>
                    <tr>
                        <td>
                            <?php echo $item['label']; ?>
                        </td>
                        <td>
                            <?php echo $item['value']; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
                <tfoot></tfoot>
            </table>
        </td>
    </tr>
    </tbody>
    <tfoot>

    </tfoot>
</table>

The code above outputs this table.

I completely understand! You’ve been a HUGE help and I expected you to move on to something else days ago, so thank you! That is actually why I posted it publically, so others could chime in since I didn’t want you to feel like it was all up to you. Again–thank you SO much! I’ll let you know as soon as I get it working.

I’m starting to have some success, but not exactly. I can get it to print the values of the property in a table–that part is great! However, it’s not replacing the ‘regularly shown’ values. This is the code:

<?php
$options = [];
if ($this->siteSetting('exclude_resources_not_in_site')) {
    $options['siteId'] = $this->currentSite()->id();
}

if ($propTerm = 'dhterm:item'){

$listItems = [];
$listValues = $resource->value($propTerm, ['all' => true]);
foreach ($listValues as $key => $listValue){
    if($listValue->type() == 'numeric:integer'){
        $listItems[] = [
            'amt' => $listValue->asHtml(),
            'it' => ($listValues[$key+1]->type() == 'literal') ? $listValues[$key+1]->asHtml() : '',
        ];
    }
}
?>

<table>
<?php foreach ($listItems as $listItem): ?>
<tr>
</td><td><?php echo $listItem['amt']; ?></td><td><?php echo $listItem['it']; ?>
</tr>
<?php endforeach; ?>
</table>
<?php } 

echo $resource->displayValues($options); ?>


It’s a table!

You’ll never guess what happened just now. I made it work!
Not the php. I’m still frustrated with that.

But after banging my head against the code for the last week, I figured I’d try one more time with CSS to see if I could get it to cooperate. And it DID!
image

I will be making a post shortly showing what I did. Again–thank you so much for your help!