List Info

Thread: Problem with alias




Problem with alias
user name
2007-06-19 05:05:41
Hi, 
I have a  site A where i publish news and a newsoverview,
all works fine.
A second site B publishes the news via "Alias",
this works fine for the news, 
but it does not work for the overview. There I publish a
Teaser and a link to 
the news, the link should be 
/%/%Y/%m/%d/%/  
but I get :  /%/%/
The news itself is published correctly.

Site A and B both have an OC defined with the same URI
Format 
(/%/%Y/%m/%d/%/ ), 
Site B as a Template Include from A

The Source for the template is :

...
% for my $art ($articles) {
%     my $elem = $art->get_element;
%     my $uri = $burner->best_uri($art)->as_string;
<a href="<% $uri %>" ....
...
and $aticles comes from 
  Bric::Biz::Asset::Business::Story->list({ ..});

Any hints ?

-- 
Regards
Rolf Schaufelberger

rsplusw.de


Re: Problem with alias
user name
2007-06-19 05:57:31
On Tue, 19 Jun 2007, Rolf Schaufelberger wrote:
> I have a  site A where i publish news and a
newsoverview, all works fine.
> A second site B publishes the news via
"Alias", this works fine for the news,
> but it does not work for the overview. There I publish
a Teaser and a link to
> the news, the link should be 
/%/%Y/%m/%d/%/
> but I get :  /%/%/
> The news itself is published correctly.
>
> Site A and B both have an OC defined with the same URI
Format
> (/%/%Y/%m/%d/%/ ),

But what about the Fixed URI Format?
An "overview" sounds like it would be a kind of
cover story
(with Fixed checked in the Element Type profile).


> Site B as a Template Include from A
>
> The Source for the template is :
>
> ...
> % for my $art ($articles) {
> %     my $elem = $art->get_element;
> %     my $uri =
$burner->best_uri($art)->as_string;
> <a href="<% $uri %>" ....

Or maybe best_uri's guess is incorrect in this case.

Re: Problem with alias
user name
2007-06-19 07:57:03
On Dienstag 19 Juni 2007, Scott Lanning wrote:
> On Tue, 19 Jun 2007, Rolf Schaufelberger wrote:
> > I have a  site A where i publish news and a
newsoverview, all works fine.
> > A second site B publishes the news via
"Alias", this works fine for the
> > news, but it does not work for the overview. There
I publish a Teaser and
> > a link to the news, the link should be 
/%/%Y/%m/%d/%/
> > but I get :  /%/%/
> > The news itself is published correctly.
> >
> > Site A and B both have an OC defined with the same
URI Format
> > (/%/%Y/%m/%d/%/ ),
>
> But what about the Fixed URI Format?
> An "overview" sounds like it would be a kind
of cover story
> (with Fixed checked in the Element Type profile).

The overview itself is displayed correct, but the contained
link to the full 
news is incorrect since the %Y%m%d part is missing. 


>
> > Site B as a Template Include from A
> >
> > The Source for the template is :
> >
> > ...
> > % for my $art ($articles) {
> > %     my $elem = $art->get_element;
> > %     my $uri =
$burner->best_uri($art)->as_string;
> > <a href="<% $uri %>" ....
>
> Or maybe best_uri's guess is incorrect in this case.

Thats how it looks to me.
I added these lines to my template:
% for my $art ($articles) {
%     my $elem = $art->get_element;
%     my $uri = $burner->best_uri($art)->as_string;
%     my $oc = $burner->get_oc();
 OC = <% $oc->get_uri_format() %><br/>
 ....

and i get: 
OC = /%/%Y/%m/%d/%/

which is correct.  Now I tried to debug best_uri, looked
into Burner.pm and 
put some debug code in my template.
I've found, that it uses $rel (is an alias) and then
switches to the 
primary_oc of hat alias, but this one ist NOT the one that
it should be. I 
just have two Oc for this site, but neither news nor
newsoverview define this 
one in any place. So where does it come from ? 

I testet ($ba->get_output_channels())[0] , and got the
sam OC as above. So why 
ist the wron OC attached to my alias ?
Again: Publishing the alias itself works OK !

Any idea ?
-- 
Regards
Rolf 


Re: Problem with alias
user name
2007-06-19 08:26:24
On Tue, 19 Jun 2007, Rolf Schaufelberger wrote:
> which is correct.  Now I tried to debug best_uri,
looked into Burner.pm and
> put some debug code in my template.
> I've found, that it uses $rel (is an alias) and then
switches to the
> primary_oc of hat alias, but this one ist NOT the one
that it should be. I
> just have two Oc for this site, but neither news nor
newsoverview define this
> one in any place. So where does it come from ?

I'm lost.... You don't know where the OC is?
Can you print $oc->get_id,
then "select * from output_channel where id = ?"
?

> I testet ($ba->get_output_channels())[0] , and got
the sam OC as above. So why
> ist the wron OC attached to my alias ?

So, let me try to understand... You're looking there in sub
best_uri.

Could you please show a really detailed debugging trace you
did,
like:

     } else {
         # The asset's not in this site. Try to lookup an
alias in this site.
         if (my $rel = $ba->lookup({ alias_id =>
$ba->get_id,
                                     site_id  => $site_id
})) {

print STDERR "ba ID: ", $ba->get_id, ",
site ID: $site_id, ",
"rel ID: ", $rel->get_id, $/;

             # Use the alias, instead.
             $ba = $rel;
             # Make sure we have an output channel that
works with this asset.
             # Try the current one, and fallback on the
default if that fails.

print STDERR "oc ID: ", $oc->get_id, $/;
my ocs = $ba->get_output_channels($oc->get_id);
print STDERR "num OCs: ", scalar(ocs),
", OC IDs: ",
join(",", map { $_->get_id } ocs),
$/;

             $oc =
($ba->get_output_channels($oc->get_id))[0] ||
               $ba->get_primary_oc;

print STDERR "chosen OC: ", $oc->get_id, $/;


so we know exactly what the values are at each place?

Then you might also have to go down into the get_uri method
(in Bric::Biz::Asset::Business::Story) and do the same
thing
until you figure it all out.

Re: Problem with alias
user name
2007-06-19 09:20:00
On Dienstag 19 Juni 2007, Scott Lanning wrote:
>    if (my $rel = $ba->lookup({ alias_id =>
$ba->get_id,
>                                      site_id  =>
$site_id })) {
>
> print STDERR "ba ID: ", $ba->get_id,
", site ID: $site_id, ",
> "rel ID: ", $rel->get_id, $/;
>
>              # Use the alias, instead.
>              $ba = $rel;
>              # Make sure we have an output channel that
works with this
> asset. # Try the current one, and fallback on the
default if that fails.
>
> print STDERR "oc ID: ", $oc->get_id, $/;
> my ocs = $ba->get_output_channels($oc->get_id);
> print STDERR "num OCs: ", scalar(ocs),
", OC IDs: ",
> join(",", map { $_->get_id } ocs),
$/;
>
>              $oc =
($ba->get_output_channels($oc->get_id))[0] ||
>                $ba->get_primary_oc;
>
> print STDERR "chosen OC: ", $oc->get_id,
$/;

Well this gives :

DEBUG: ba ID: 1134, site ID: 1197, rel ID: 1152
oc ID: 1034
num OCs: 1, OC IDs: undef (!!!)
chosen OC: 1033

Scalar(ods) gives 1, but ods[0] gives undef !, so I had to
modify your code a 
bit.

But this oc (1033) is not assigned to the Element_types used
here, but to 
others used in Site B! 

I could solve my problem by deleting all aliased stories
I've created today, 
some of them had indeed the wrong OC with them. I had
deleted these profiles 
in the UI, but they are kept in the database and it looks
like the 
get_output_channel function does't watch the active flag or
whatever. Now I 
deleted them in the table story and it works.


Regards
Rolf Schaufelberger


Re: Problem with alias
user name
2007-06-19 10:03:42
On Tue, 19 Jun 2007, Rolf Schaufelberger wrote:
> in the UI, but they are kept in the database and it
looks like the
> get_output_channel function does't watch the active
flag or whatever.

Yeah, I bet that's the problem.
Could you try:

Index: lib/Bric/Biz/OutputChannel.pm
============================================================
=======
--- lib/Bric/Biz/OutputChannel.pm       (revision 7925)
+++ lib/Bric/Biz/OutputChannel.pm       (working copy)
 -1754,6
+1754,10 
      my $tables = $pkg->SEL_TABLES;
      my $wheres = $pkg->SEL_WHERES;
      my params;
+
+    $params-> = (exists $params-> and
!$params->)
+      ? 0 : 1;
+
      while (my ($k, $v) = each %$params) {
          if ($k eq 'id' or $k eq 'uri_case') {
              # Simple numeric comparison.


Though I'm not sure if it's safe to assume that
OutputChannel->list
defaults to active=1.

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )