Is it possible to assign the banner based on which primary link is currently displayed?

As in:

Primary Links:
:Welcome - A happy face smiling
:Forums - A bunch of happy faces smiling
:Bug submission - An angry face very unhappy
etc....

I'm looking at the code but am not yet familiar enough with this kind of linkage in themes.

By the way - This is a great theme - Good work! Kudos!

Daniel

CommentFileSizeAuthor
#1 marinelli_BannersByTitle.tar_.gz749.95 KBdchapiesky
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dchapiesky’s picture

Assigned: Unassigned » dchapiesky
Status: Active » Needs review
FileSize
749.95 KB

Got it working...

I sat down and wrote the mods and am submitting for your approval...

Create a page called "Welcome" and another called "About Us" and see how marinelli_BannerByTitle works....

Just put banners in ./img/banners/bytitle with filenames in lowercase - no spaces - and the title of your page will display the associated banner.

If no banner is assigned, it will continue to randomly assign banners from ./img/banners

See ./BannersByTitle.txt for info what changes were made...
See ./img/banners/AssignByTitle.php for extensive comments on the modification of rotate.php...

[note: in order to make it under the 1M upload limit, I had to remove some of the jpg's from ./img/banners...]

bryancasler’s picture

Category: feature » bug
Status: Needs review » Postponed (maintainer needs more info)

I'm getting errors. The banner rotation is working, but the title assignment is not, I get the full page error
If you are the owner of this web site you have not uploaded (or incorrectly uploaded) your web site. For information on uploading your web site using FTP client software or web design software, click here for FTP Upload Information.

page.tpl.php

<style type="text/css" >
	#header {
		padding: 0;
		margin: 0;
		height: 200px;
		position:relative;
		<?php print 'background: #000033 url('.litejazz_banner().') no-repeat 0px 0px;' ?>
	}
</style>

template.php

function litejazz_banner() {
  $theTitleName = str_replace(' ', '', strtolower(drupal_get_title()));

  $theBannerUrl = base_path().path_to_theme()."/images/banners/AssignByTitle.php?title=".$theTitleName;
  return $theBannerUrl;
}

**Shouldn't it be (AssignByTitle.php?img=) as suggested in your comments ? However, neither variation worked for me. Any suggestions are welcomed.

dchapiesky’s picture

LOL... (not you... it's just interesting how quickly code can be pulled and changed and come back to you in new ways...)

AssignByTitle.php?img= : ?img= was actually part of the original rotate.php code... I added ?title= to keep the two actions separate from each other..

?img= has to have a complete path to the image being displayed
?title= takes the name provided and looks in the byTitle directory for it...

---------------------------

Since the name of the code is litejaz_banner rather than marinnelli_banner, I assume the code was copied from one to the other... It may be that not all of the modifications were transposed properly....

The error message suggests that the byTitle directory does not have correct permissions set within it....

If you have an images directory for other stuff, you can move your banners there and modify the target directory as set in AssignByTitle.php

-------------------------------

If the title has commas or other non alphanumeric characters, that could cause problems also...

I may work on stripping these characters from the title in the next version...

-------------------------------

Do you have the site up for me to look at?

Daniel

mentus’s picture

Hi dchapiesky,

thanks for Your valuable contribution.

i tried it out, but it doesn't work for some reason...

i downloaded the whole theme marinelli_BannersByTitle, included in Your above post. i copied all my images (named after the primary links in lower case) in the folder ./img/banners/bytitle and uploaded the whole theme onto my drupal server and set it as the default theme. The assignment doesn't work however, the three images which are in the folder ./img/banners are being rotated...

i checked already the supposed mistakes in the code as mentioned by animelion, but in the version i downloaded everything seems to be ok.

Could You please tell me what might be wrong?

Thank You very much
mentus

mentus’s picture

mentus’s picture

Hi dchapiesky,

thanks for Your valuable contribution.

i tried it out, but it doesn't work for some reason...

i downloaded the whole theme marinelli_BannersByTitle, included in Your above post. i copied all my images (named after the primary links in lower case) in the folder ./img/banners/bytitle and uploaded the whole theme onto my drupal server and set it as the default theme. The assignment doesn't work however, the three images which are in the folder ./img/banners are being rotated...

i checked already the supposed mistakes in the code as mentioned by animelion, but in the version i downloaded everything seems to be ok.

Could You please tell me what might be wrong?

Thank You very much
mentus

dchapiesky’s picture

Sorry.. was on vacation... back now...

Off the top of my head I think your problem is the primary links.... the name of the banner should be the page title in lowercase with no spaces... I'm working on the theme now and will do some more work to flesh it out better.

animelion appears to have ported the code from marinelli into some other theme.... so I don't know if they got that bit working.

Daniel

mentus’s picture

Thanks for Your response.

Still i think i have done everything correctly, as it seems...

i put all my image banners into the theme folder .\img\banners\bytitle
i named them according to the primary links and that in lower case. Here is the file content of the folder "bytitle":

bhakti-yoga.jpg
kontakt.jpg
kulturellerhintergrund.jpg
links.jpg
medienecke.jpg
startseite.jpg
suchen.jpg
veranstaltungen.jpg
zentrum.jpg

Perhaps You could check the primary links on the website: http://www.gaura-bhakti.ch

i hope You can help me further
thanks

mrbrowny’s picture

Version: 6.x-1.6 » 6.x-2.2
Category: bug » feature
Priority: Normal » Critical

Hi, i didn't test the changes of dchapiesky, but i was looking for this feature for a long time.
Would the owner include this functionality in the next release?

It would be very helpful for me to have this feature of banner assignment, as it is a must have for my projects using this theme. Banner rotation me also be used, because its pretty helpful by now.

Thanks in advance.

Claudio Abraham
(mrbrowny)

mrbrowny’s picture

Mentus read... he says "PAGE TITLE" so the title of the article, and you are saying "PRIMARY LINKS" so the texts of the menues. Both may be linked but are different things.

If you have a Link in Primary Links that says "Kontakt" you need to point that link to a page content called also "Kontakt".

I will try to review this feature today, so may be changed as "reviewed and tested by the comunity".

See ya tomorrow!

Claudio Gaston Abraham
(mrbrowny in Drupal)
Argentina
South America

oadaeh’s picture

Assigned: dchapiesky » Unassigned
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-4.x branch.
Thank you.