Jump to content

oscarale

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by oscarale

  1. Hello, I have a multi-language site that has static content which differs between each language, so I have disabled multi-language support in each template's settings, except for one, the contact page, that is using FrontendForms so I found I needed to use the multi-language support to get that page translated. My issue is that when I start to navigate away from that page, I now have the languages prefix in the url, regardless of whether or not the page's template has the multi-language support disabled or not. Is there a way to remove that prefix for pages that have this setting disabled? For reference, here is my (simplified) page structure with urls Home (Language picker) | "example.com" English US Content | "example.com/en-us" English UK Content | "example.com/en-uk" Spanish ES Content | "example.com/es-es" Contact (PW Multi-language in english and spanish) | "example.com/contact" & "example.com/es/contacto" Now let's say I follow this navigation path: Home | "example.com" Choose spanish content | "example.com/es-es" Click on contact form link | "example.com/es/contacto" Fill out and send form, click on link to go back home | "example.com/es" Navigate to english content | "example.com/es/en-us" I now have my url as "example.com/es/en-us" instead of "example.com/en-us". The page works, but it's just slightly annoying and confusing that this is in the url now. How could I remove this? Thanks!
  2. Interesting approach, adding lines word by word would definitely be less error prone, but it seems cumbersome to input and update lyrics this way, as opposed to just writing it out in a textarea type field. I'll keep an eye on your project though it looks promising!
  3. Thanks everyone. I ended up using the solution @diogo posted since it seemed the simplest and it works great. I was even able to leave off the '!important'.
  4. Forgive my ignorance, but I'm still not sure how site/templates/admin.less will be able to update the styling on my edit page. I did however find in the source that it is pulling from wire/templates-admin/styles/AdminTheme.css, so I added this line to the end and it changed the font, though I'm not sure if this is the correct way to go about this. textarea[name^="song_lyrics"] { font-family: monospace !important; } Thanks for your help!
  5. I can't figure out how to do this, there's not an admin.less file in site/templates, or if I need to create it I'm not sure how to specify that the specific lyric field should use a monospace font
  6. Got it working! Thanks for that AI suggestion @bernhard it did a lot of the leg work for me, and thanks @diogo for your suggestion as well, though it is easier to read and write the standard format with the chords above the lyrics. While there is software that will do the parsing to the chords within the lyrics for me (there's one called ChordPro) I was trying to remove the "middle man" so to speak and be able to edit and create lyrics directly and easily in ProcessWire. If anyone else is interested below is the code which creates an array with all the columns, sections and lines $started_chords = false; $chord_line = ""; $lyric = [[]]; $column = 0; $section = -1; foreach (explode("\n", $page->psalm_lyrics) as $line) { $stripped = preg_replace('/\s+/', ' ', trim($line)); if ($stripped) { if (array_key_exists($stripped, $sections)) { // START SECTION $section++; $lyric[$column][] = [ "class" => $sections[$stripped], "lines" => [] ]; } elseif (empty(array_diff(explode(" ", $stripped), $chords)) && !$started_chords) { $started_chords = true; $chord_line = $line; } elseif ($stripped === "---") { $lyric[] = []; $column++; $section = -1; } else { if ($started_chords) { $started_chords = false; $chord_line = rtrim($chord_line); $limit = 0; while ($chord_line && $limit < 10) { $i = strrpos($chord_line, " ") ? strrpos($chord_line, " ") + 1 : 0; $stripped = mb_substr($stripped, 0, $i, 'UTF-8') . "<span class='chord'>" . mb_substr($chord_line, $i, null, 'UTF-8') . "</span>" . mb_substr($stripped, $i, null, 'UTF-8'); $chord_line = rtrim(mb_substr($chord_line, 0, $i, 'UTF-8')); $limit++; } } $lyric[$column][$section]["lines"][] = $stripped; } } } Where $sections is a ProcessWire repeater field that parses different starts of sections like [VERSE] and [CHORUS] and then translates those to a class, and $chords is an array of available chords to parse. I can then write out the lyric wherever I need it. <div class="lyrics mt-md"> <?php foreach($lyric as $c) { echo "<div class='column'>"; foreach($c as $s) { echo "<div class='section " . $s['class'] . "'>"; foreach($s["lines"] as $l) { echo "<p class='line'>$l</p>"; } echo "</div>"; } echo "</div>"; } ?> </div> So this lyric for example: [CHORUS] E D G B I'll take you for a ride E D G B On my garbage truck B A Oh no --- [VERSE] E D G B I'll take you to the dump E D G B 'Cuz you're my queen A C Take you uptown A C I'll show you the sights C D You know you wanna ride Will render like this
  7. Hello everyone, I have some lyrics with chords as text, formatted like this: [Verse] E D G B I'll take you for a ride E D G B On my garbage truck B A Oh no Which I write out like this in html: <div class='lyric'> <div class='section' data-section='verse'> <p class='line'><span class='chord'>E</span>I'll take you <span class='chord'>D</span>for a r<span class='chord'>G</span>ide<span class='chord'>B</span></p> <p class='line'><span class='chord'>E</span>On my ga<span class='chord'>D</span>rbage t<span class='chord'>G</span>ruck<span class='chord'>B</span></p> <p class='line'><span class='chord'>B</span>Oh no<span class='chord'>A</span></p> </div> </div> So that it gets rendered like this: I have a python script which converts my lyric/chord files into the html above, which I then paste into a Textarea field that gets put into my template and rendered out on a page for each song. What I'm wondering is if there's a way to do this through ProcessWire without the python script? So instead of pasting html into the Textarea field, I can type out the lyrics in the field and ProcessWire parses it to output the proper html? I'm thinking I may have to write my own Textformatter but I'm not sure if that's the right solution or where to start. Thanks!
  8. Thanks for the tutorial! I didn't integrate the "search as you type" ajax and instead just hijacked the submit button to perform the search using the same method as you explained, and it works great!
×
×
  • Create New...