I, the developer, need some help from an expert on this...

My module uses hook_nodeapi - $op = alter to parse and modify some parts of a node's body.

A user of my module uses $node->content['body']['#value'] in his theme and reported that there were problems... #565358: Using the "Only link first occurance of term" option fails to work

I am currently parsing $node->body (and ->teaser too...)

@all: Is it safe and what are the implications of using $node->content['body']['#value'] ??

Comments

rsvelko’s picture

quote from a user:
---
Glossify works only if content parsing by print $content in node.tpl.php
I want Glossify to work with print $node->content['body']['#value'] because of my complex node template and for capability to other CCK fields.
---

rsvelko’s picture

can somebody point to some docs or explain to me - what is $node->content and why should glossify use it?
Is it safe?

Ivo.Radulovski’s picture

it should be safe using it - maybe this is the right approach for making Glossify work with cck fields too.

Correct me if I'm wrong....but if you take this you can choose all fields - so maybe in future you could decide trough the interface which of your fields are parsed through glossify

something like this


<?php

foreach($node->content as $key => $field) {
   
 if ($field /* is in some array checked inside glossify */ )
    { /* parse the  field value */ $field['#value']; }
}
    

?>



rsvelko’s picture

90% sure that cck fields are in there too.

Testing if all works with changing ->body to ->content[body][value] .

Maybe content means that this element of the object comes from the content module (the name of the core module in the cck project(=package) in d6 )

Ivo.Radulovski’s picture

but if and which cck's are parsed should maybe set-able what do you think?

rsvelko’s picture

af kors. I strongly suppose that this in effect will lead to glossify beginning to magically work in views.

jcbou’s picture

Version: 6.x-2.0-rc1 » 6.x-2.3
Category: task » feature

Double on this. It would be great. I'm using a complex template with CCK fields, so i cannot get Glossify to work with it.

rsvelko’s picture

Status: Active » Postponed

I tried to modify $node->content in hook_nodeapi, $op = alter. Nothing happens. Only when I try with $node->body it towrks. So , postponed until someone gives advice or finds someone more knowledge-able. I've done research but in vain.

Fienix’s picture

Subscribe

locomo’s picture

subscribe

kristi wachter’s picture

Hi rsvelko,

I use $node->content extensively, and I'd like to chime in a bit.

I use $node->content to get very fine control over how content appears. A lot of my clients have very precise specifications for how they want their pages to look - there are lots of CCK fields, and they have to be arranged in very specific ways. Using $content, even with the options available on Content Type -> Display Fields, doesn't give me the level of control I need.

So, instead, my node-contenttype.tpl.php will often have stuff like this:

<div class="header">
	<h1><?php echo $node->title; ?></h1>
<?php if (strlen($node->field_badge_name[0]['value']) > 0) { ?>
	<p><span class="label-<?php echo $node->field_badge_color[0]['value']; ?>"><?php echo $node->field_badge_name[0]['value']; ?></span></p>
<? } ?>
</div>
<div class="details">
	<ul class="labeled-a">
		<li><strong>Member since:</strong> <?php echo format_date($created,'custom','F d, Y'); ?></li>
<?php if (($user_loc['city'] != '') && ($user_loc['province'] != '')) { ?>
		<li><strong>Location:</strong> <?php echo $user_loc['city'] . ', ' . $user_loc['province']; ?></li>
<?php } ?>
<?php 
$fanned_nodes = views_embed_view('flag_bookmarks_tab', 'panel_pane_1', $uid); 
if (strpos($fanned_nodes, 'has not yet') == 0) { ?>
		<li><strong>I'm a fan:</strong> <?php echo views_embed_view('flag_bookmarks_tab', 'panel_pane_1', $uid); ?></li>
<?php } ?>
		<li class="off"><strong>Bio:</strong> <?php echo $node->field_bio[0]['view']; ?></li>
	</ul>
</div>

So, that's why I use $node->content (and $node->field_fieldname).

Now:

I took a quick look at glossify.module . I saw where you had tried working with content:

//  $node_body   = $node->content['body']['#value'];

I uncommented that line, and then copied this (line 290? or so):

        $node->body = __glossify_parse_html_text_and_replace_terms_safely($node_body, $glossify_dict_titles,  $replacements);

and duplicated it, modified, like this:

        $node->content['body']['#value'] = __glossify_parse_html_text_and_replace_terms_safely($node_body, $glossify_dict_titles,  $replacements);

And THAT WORKS in my highly modified theme.

Before making this change, I was experiencing what others had:

* Glossify did not work with my custom theme
* Glossify did work for me in Garland

Obviously, this isn't enough investigation for me to put together a patch - but since you had asked for some additional background, I thought I'd write this up in case it helped.

Thanks!

Beatle88’s picture

Hi,

I had the same problem - glossify not working with the garland theme, and I managed to get it working to a degree with the code above. All nodes have the links except ones that I had used the Panels module on - creating a variant in the panels node template and overriding the original node template. Does anyone have any idea why this might be the case and what I could do about it?

*Update*
Missed this discussion
http://drupal.org/node/668592
Looks like my problem...

Ivo.Radulovski’s picture

Version: 6.x-2.3 » 6.x-3.x-dev
Assigned: Unassigned » Ivo.Radulovski
Status: Postponed » Needs work

Thanks for the info - we will review this and have a look in the 3.x - dev version

cygii’s picture

Doesn't work for me.

Garry Egan’s picture

Could really use a solid solution for this guys. Built this monster killer site. CCK to the max. Glossify no worky which means I've been having to hand-link hundreds of pages.

Garry Egan’s picture

No solutions presented worked for me either. Even tried version 3.x dev. Nothing. It's all setup like it wants to work...fields and issues addressed...except when you go to render the page, no links. I am using caching.

WorldFallz’s picture

Assigned: Ivo.Radulovski » Unassigned
Status: Needs work » Active

'needs work' is for issues with a patch.

WorldFallz’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

no further development for d6 unless patch is included.